Class: Immutabler::Template::BaseTemplate

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

Direct Known Subclasses

BodyTemplate, HeaderTemplate

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#template_fileObject

Returns the value of attribute template_file.



12
13
14
# File 'lib/immutabler/template/template.rb', line 12

def template_file
  @template_file
end

Instance Method Details

#handlebarsObject



18
19
20
# File 'lib/immutabler/template/template.rb', line 18

def handlebars
  @handlebars ||= Handlebars::Context.new
end

#helper(name, &helper_body) ⇒ Object



26
27
28
29
30
# File 'lib/immutabler/template/template.rb', line 26

def helper(name, &helper_body)
  handlebars.register_helper(name) do |context, arg, block|
    helper_body.call(context, arg, block).unindent
  end
end

#raw_templateObject



14
15
16
# File 'lib/immutabler/template/template.rb', line 14

def raw_template
  @raw_template ||= File.read(template_file)
end

#templateObject



22
23
24
# File 'lib/immutabler/template/template.rb', line 22

def template
  @template ||= handlebars.compile(raw_template, {noEscape: true})
end