Class: Makanai::TemplateEngine::Haml

Inherits:
Base
  • Object
show all
Defined in:
lib/makanai/template_engine/haml.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, locals: {}) ⇒ Haml

Returns a new instance of Haml.



9
10
11
12
13
# File 'lib/makanai/template_engine/haml.rb', line 9

def initialize(text:, locals: {})
  super()
  @text = text
  @locals = locals
end

Instance Attribute Details

#localsObject (readonly)

Returns the value of attribute locals.



15
16
17
# File 'lib/makanai/template_engine/haml.rb', line 15

def locals
  @locals
end

#textObject (readonly)

Returns the value of attribute text.



15
16
17
# File 'lib/makanai/template_engine/haml.rb', line 15

def text
  @text
end

Instance Method Details

#resultObject



17
18
19
20
# File 'lib/makanai/template_engine/haml.rb', line 17

def result
  # ref: http://haml.info/docs/yardoc/Haml/Engine.html#render-instance_method
  ::Haml::Engine.new(text).render(Object.new, locals)
end