Module: Musterb

Defined in:
lib/musterb.rb,
lib/musterb/version.rb

Defined Under Namespace

Modules: ExtractValues Classes: BindingExtractor, Chain, Evaluator, HashExtractor, Musterbifier, NullExtractor, ObjectExtractor, TemplateHandler

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.render(template, values) ⇒ Object



24
25
26
# File 'lib/musterb.rb', line 24

def self.render(template, values)
  Erubis::Eruby.new(to_erb template).result(values)
end

.to_erb(template, options = {}) ⇒ Object



17
18
19
20
21
22
# File 'lib/musterb.rb', line 17

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::Evaluator.new(#{initial_context}).tap do |musterb| %>#{musterbifier.to_erb}<% end %>"
end