Class: Thymeleaf::Rails::ThymeleafHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/thymeleaf/rails/handler.rb

Instance Method Summary collapse

Instance Method Details

#call(template) ⇒ Object



12
13
14
# File 'lib/thymeleaf/rails/handler.rb', line 12

def call(template)
  do_render(template.source, template.locals)
end

#do_render(template_content, locals) ⇒ Object



5
6
7
8
9
10
# File 'lib/thymeleaf/rails/handler.rb', line 5

def do_render(template_content, locals)
  str = 'th_context = {};'
  str << 'instance_variables.map { |name| th_context[name[1..-1]] = instance_variable_get(name) if name[0].eql?"@" };'
  str << "Thymeleaf::Template.new('#{template_content}', th_context).render.to_s"
  str
end