Module: Brine::MustacheExpanding
- Included in:
- Brine
- Defined in:
- lib/brine/mustache_expanding.rb
Overview
Provides a binding environment and template expansion that uses that environment.
Instance Method Summary collapse
-
#bind(key, value) ⇒ Object
Assign ‘value’ to ‘key’ within binding,.
-
#binding ⇒ Hash<String, Object>
Mutable hash which serves as binding environment.
-
#shave_value(template) ⇒ String
Expanded Mustache template using binding environment.
Instance Method Details
#bind(key, value) ⇒ Object
Assign ‘value’ to ‘key’ within binding,
29 30 31 32 |
# File 'lib/brine/mustache_expanding.rb', line 29 def bind(key, value) STDERR.puts "Assigning #{value} to #{key}" if ENV['BRINE_LOG_BINDING'] binding[key] = value end |
#binding ⇒ Hash<String, Object>
Mutable hash which serves as binding environment.
19 20 21 |
# File 'lib/brine/mustache_expanding.rb', line 19 def binding @binding ||= {} end |
#shave_value(template) ⇒ String
Expanded Mustache template using binding environment. Mustache in…no Mustache out.
41 42 43 |
# File 'lib/brine/mustache_expanding.rb', line 41 def shave_value(template) Mustache.render(template, binding) end |