Class: Immutabler::Template::BaseTemplate
- Inherits:
-
Object
- Object
- Immutabler::Template::BaseTemplate
show all
- Defined in:
- lib/immutabler/template/template.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#template_file ⇒ Object
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
#handlebars ⇒ Object
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_template ⇒ Object
14
15
16
|
# File 'lib/immutabler/template/template.rb', line 14
def raw_template
@raw_template ||= File.read(template_file)
end
|
#template ⇒ Object
22
23
24
|
# File 'lib/immutabler/template/template.rb', line 22
def template
@template ||= handlebars.compile(raw_template, {noEscape: true})
end
|