Module: MustacheBinder
- Included in:
- Brine
- Defined in:
- lib/brine/mustache_binder.rb
Overview
Provides a binding environment and template expansion functions that use that environment
Instance Method Summary collapse
-
#bind(key, value) ⇒ Object
assign ‘value’ to ‘key’ within binding defined in a method to allow observability/interception.
-
#binding ⇒ Object
getter for mutable hash which serves as binding environment.
-
#shave_value(val) ⇒ Object
return value as expanded Mustache template using binding environment Mustache in…no Mustache out.
Instance Method Details
#bind(key, value) ⇒ Object
assign ‘value’ to ‘key’ within binding defined in a method to allow observability/interception
14 15 16 17 |
# File 'lib/brine/mustache_binder.rb', line 14 def bind(key, value) puts "Assigning #{value} to #{key}" if ENV['BRINE_LOG_BINDING'] binding[key] = value end |
#binding ⇒ Object
getter for mutable hash which serves as binding environment
8 9 10 |
# File 'lib/brine/mustache_binder.rb', line 8 def binding @binding ||= {} end |
#shave_value(val) ⇒ Object
return value as expanded Mustache template using binding environment Mustache in…no Mustache out
21 22 23 |
# File 'lib/brine/mustache_binder.rb', line 21 def shave_value(val) Mustache.render(val, binding) end |