Class: Brine::MustacheExpanding::BrineTemplate
- Inherits:
-
Mustache
- Object
- Mustache
- Brine::MustacheExpanding::BrineTemplate
- Defined in:
- lib/brine/mustache_expanding.rb
Overview
Provide an expandable Mustache template using binding environment.
This exists to support latent expansion and template retrieval.
Instance Method Summary collapse
-
#expand(binding) ⇒ String
Expand the template using the provided bindings.
-
#initialize(tmpl) ⇒ BrineTemplate
constructor
Instantiate a BrineTemplate.
-
#to_s ⇒ Object
Stringify as template contents.
Constructor Details
permalink #initialize(tmpl) ⇒ BrineTemplate
Instantiate a BrineTemplate.
45 46 47 |
# File 'lib/brine/mustache_expanding.rb', line 45 def initialize(tmpl) @template = tmpl end |
Instance Method Details
permalink #expand(binding) ⇒ String
Expand the template using the provided bindings.
55 56 57 58 59 60 61 62 |
# File 'lib/brine/mustache_expanding.rb', line 55 def (binding) begin context.push(binding) render ensure context.pop end end |
permalink #to_s ⇒ Object
Stringify as template contents.
This supports cases such as dynamic steps where a string is expected but the template should not yet be expanded.
70 71 72 |
# File 'lib/brine/mustache_expanding.rb', line 70 def to_s @template end |