Class: RogerStyleGuide::Templates::Mustache::MustacheTemplate
- Inherits:
-
Mustache
- Object
- Mustache
- RogerStyleGuide::Templates::Mustache::MustacheTemplate
- Defined in:
- lib/roger_style_guide/templates/mustache/mustache_template.rb
Overview
Mustach template wrapper which handles partial resolving.
Instance Attribute Summary collapse
-
#template_context ⇒ Object
readonly
Returns the value of attribute template_context.
Instance Method Summary collapse
Instance Attribute Details
#template_context ⇒ Object (readonly)
Returns the value of attribute template_context.
7 8 9 |
# File 'lib/roger_style_guide/templates/mustache/mustache_template.rb', line 7 def template_context @template_context end |
Instance Method Details
#partial(name) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/roger_style_guide/templates/mustache/mustache_template.rb', line 18 def partial(name) path = @template_context.component_template_paths(name.to_s + ".mst").find do |template_path| result = @template_context.renderer.send(:find_partial, template_path) break result if result end if path File.read(path) else fail "No such Mustache partial found: #{name}" end end |
#render(template, data, template_context = nil) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/roger_style_guide/templates/mustache/mustache_template.rb', line 9 def render(template, data, template_context = nil) if template_context @template_context = template_context elsif data.respond_to?(:template_context) @template_context = data.template_context end super(template, data) end |