Module: Musterb
- Defined in:
- lib/musterb.rb,
lib/musterb/version.rb
Defined Under Namespace
Modules: ExtractValues
Classes: BindingExtractor, Chain, Evaluator, HashExtractor, InstanceVariableExtractor, Musterbifier, NullExtractor, ObjectExtractor, RailsLocalsExtractor, TemplateHandler
Constant Summary
collapse
- VERSION =
"1.0.1"
Class Method Summary
collapse
Class Method Details
.render(template, values) ⇒ Object
26
27
28
|
# File 'lib/musterb.rb', line 26
def self.render(template, values)
Erubis::Eruby.new(to_erb template).result(values)
end
|
.to_erb(template, options = {}) ⇒ Object
19
20
21
22
23
24
|
# File 'lib/musterb.rb', line 19
def self.to_erb(template, options = {})
klass = options[:musterbifier_klass] || Musterbifier
musterbifier = klass.new(template)
initial_context = options[:initial_context] || 'Musterb::BindingExtractor.new(binding, Musterb::NullExtractor.new)'
"<% Musterb::Evaluator.new(#{initial_context}).tap do |musterb| %>#{musterbifier.to_erb}<% end %>"
end
|