Class: Slippers::Engine
- Inherits:
-
Object
- Object
- Slippers::Engine
- Defined in:
- lib/engine/engine.rb
Constant Summary collapse
- DEFAULT_STRING =
''
- MISSING_HANDLER =
lambda { return "" }
Instance Attribute Summary collapse
-
#main_template ⇒ Object
readonly
Returns the value of attribute main_template.
-
#template_group ⇒ Object
readonly
Returns the value of attribute template_group.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(template, params = {}) ⇒ Engine
constructor
A new instance of Engine.
- #render(object_to_render = nil) ⇒ Object
Constructor Details
Instance Attribute Details
#main_template ⇒ Object (readonly)
Returns the value of attribute main_template.
11 12 13 |
# File 'lib/engine/engine.rb', line 11 def main_template @main_template end |
#template_group ⇒ Object (readonly)
Returns the value of attribute template_group.
11 12 13 |
# File 'lib/engine/engine.rb', line 11 def template_group @template_group end |
Instance Method Details
#eql?(other) ⇒ Boolean
20 21 22 |
# File 'lib/engine/engine.rb', line 20 def eql?(other) @main_template.eql?(other.main_template) && @template_group.eql?(other.template_group) end |
#hash ⇒ Object
24 25 26 |
# File 'lib/engine/engine.rb', line 24 def hash @main_template.hash + @template_group.hash*23 end |
#render(object_to_render = nil) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/engine/engine.rb', line 13 def render(object_to_render=nil) parser = SlippersParser.new parse_tree = parser.parse(@main_template.template) return '' unless parse_tree parse_tree.eval(object_to_render, @template_group) end |