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.



139
140
141
142
143
# File 'lib/baby_erubis.rb', line 139

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

Instance Method Details

#[](key) ⇒ Object



145
146
147
# File 'lib/baby_erubis.rb', line 145

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

#[]=(key, value) ⇒ Object



149
150
151
# File 'lib/baby_erubis.rb', line 149

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

#escape(value) ⇒ Object



153
154
155
# File 'lib/baby_erubis.rb', line 153

def escape(value)
  return value.to_s
end