Module: Brine::MustacheExpanding

Included in:
Brine
Defined in:
lib/brine/mustache_expanding.rb

Overview

Provide a binding environment and template expansion that can use such an environment.

Defined Under Namespace

Classes: BrineTemplate

Instance Method Summary collapse

Instance Method Details

#as_template(str) ⇒ BrineTemplate

Allow retrieval of BrineTemplates for provided template content.

Parameters:

  • str (String)

    Define the string contents for the returned template.

Returns:

  • (BrineTemplate)

    Return a BrineTemplate with the provided content.



81
82
83
# File 'lib/brine/mustache_expanding.rb', line 81

def as_template(str)
  BrineTemplate.new(str)
end

#bind(key, value) ⇒ Object

Assign ‘value’ to ‘key’ within binding,

Parameters:

  • key (String)

    Specify the key in the binding to which ‘value` will be assigned.

  • value (Object)

    Specify the value to assign to “key` within the binding.



28
29
30
31
# File 'lib/brine/mustache_expanding.rb', line 28

def bind(key, value)
  STDERR.puts "Assigning #{value} to #{key}" if ENV['BRINE_LOG_BINDING']
  binding[key] = value
end

#bindingHash<String, Object>

Furnish a mutable hash to serve as a binding environment.

Returns:

  • (Hash<String, Object>)

    Return the active binding environment.



18
19
20
# File 'lib/brine/mustache_expanding.rb', line 18

def binding
  @binding ||= {}
end