Class: BabyErubis::TemplateContext

Inherits:
Object
  • Object
show all
Defined in:
lib/baby_erubis.rb

Direct Known Subclasses

HtmlTemplateContext

Instance Method Summary collapse

Constructor Details

#initialize(vars = {}) ⇒ TemplateContext

Returns a new instance of TemplateContext.



171
172
173
174
175
# File 'lib/baby_erubis.rb', line 171

def initialize(vars={})
  vars.each do |k, v|
    instance_variable_set("@#{k}", v)
  end if vars
end

Instance Method Details

#[](key) ⇒ Object



177
178
179
# File 'lib/baby_erubis.rb', line 177

def [](key)
  return instance_variable_get("@#{key}")
end

#[]=(key, value) ⇒ Object



181
182
183
# File 'lib/baby_erubis.rb', line 181

def []=(key, value)
  instance_variable_set("@#{key}", value)
end

#escape(value) ⇒ Object



185
186
187
# File 'lib/baby_erubis.rb', line 185

def escape(value)
  return value.to_s
end