Sha256: ad8dd16e9985d8249d2a39a6447b1c5d1f26c4194be83d95ddd42f5f42c1bf03

Contents?: true

Size: 643 Bytes

Versions: 6

Compression:

Stored size: 643 Bytes

Contents

require 'mustache'

# Provides a binding environment and template expansion functions that use that
# environment
module MustacheBinder

  # getter for mutable hash which serves as binding environment
  def binding
    @binding ||= {}
  end

  # assign `value' to `key' within binding
  # defined in a method to allow observability/interception
  def bind(key, value)
    puts "Assigning #{value} to #{key}" if ENV['BRINE_LOG_BINDING']
    binding[key] = value
  end

  # return value as expanded Mustache template using binding environment
  # Mustache in...no Mustache out
  def shave_value(val)
    Mustache.render(val, binding)
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
brine-dsl-0.9.0 lib/brine/mustache_binder.rb
brine-dsl-0.8.1 lib/brine/mustache_binder.rb
brine-dsl-0.8.0 lib/brine/mustache_binder.rb
brine-dsl-0.7.0 lib/brine/mustache_binder.rb
brine-dsl-0.6.0 lib/brine/mustache_binder.rb
brine-dsl-0.5.0 lib/brine/mustache_binder.rb