Class: Txbr::Template

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, source, prerender_variables = {}) ⇒ Template

Returns a new instance of Template.



5
6
7
8
9
10
11
# File 'lib/txbr/template.rb', line 5

def initialize(id, source, prerender_variables = {})
  @id = id

  @liquid_template = ::Liquid::Template.parse(
    prerender(source, prerender_variables)
  )
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/txbr/template.rb', line 3

def id
  @id
end

#liquid_templateObject (readonly)

Returns the value of attribute liquid_template.



3
4
5
# File 'lib/txbr/template.rb', line 3

def liquid_template
  @liquid_template
end

Instance Method Details

#each_content_tagObject



13
14
15
16
17
18
19
20
# File 'lib/txbr/template.rb', line 13

def 
  return to_enum(__method__) unless block_given?

  .each do ||
    next unless translation_enabled?
    yield 
  end
end

#renderObject



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

def render
  liquid_template.render
end

#rootObject



26
27
28
# File 'lib/txbr/template.rb', line 26

def root
  liquid_template.root
end