Class: Tilt::MustacheTemplate
- Inherits:
-
Template
- Object
- Template
- Tilt::MustacheTemplate
- Defined in:
- lib/tilt/mustache_template.rb
Instance Method Summary collapse
Instance Method Details
#evaluate(scope, locals, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tilt/mustache_template.rb', line 19 def evaluate scope, locals, &block mustache_locals = locals.dup template = assign_template_and_front_matter! mustache_locals, data assign_instance_variables! mustache_locals, scope assign_helper_methods! mustache_locals mustache_locals[:yield] = yield if block_given? mustache_locals[:content] = mustache_locals.fetch(:yield, '') @output = ::Mustache.render(template, mustache_locals) end |
#initialize_engine ⇒ Object
8 9 10 11 |
# File 'lib/tilt/mustache_template.rb', line 8 def initialize_engine return if defined? ::Mustache require_template_library 'mustache' end |
#prepare ⇒ Object
13 14 15 16 17 |
# File 'lib/tilt/mustache_template.rb', line 13 def prepare ::Mustache.template_path = file.sub File.basename(file), '' if file @engine = ::Mustache.new @output = nil end |