Class: Yarrow::Output::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/yarrow/output/context.rb

Overview

Provides a data context for rendering a template.

Methods provided by this class become available as named variables in Mustache templates.

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Context

Returns a new instance of Context.



8
9
10
11
12
13
# File 'lib/yarrow/output/context.rb', line 8

def initialize(attributes)
  metaclass = class << self; self; end
  attributes.each do |name, value|
    metaclass.send :define_method, name, lambda { value }
  end
end