Class: LMDocstache::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/lm_docstache/renderer.rb

Constant Summary collapse

BLOCK_REGEX =
/\{\{([\#\^])([\w\.]+)(?:(\s(?:==|~=)\s?.+?))?\}\}.+?\{\{\/\k<2>\}\}/m

Instance Method Summary collapse

Constructor Details

#initialize(xml, data) ⇒ Renderer

Returns a new instance of Renderer.



5
6
7
8
# File 'lib/lm_docstache/renderer.rb', line 5

def initialize(xml, data)
  @content = xml
  @data = DataScope.new(data)
end

Instance Method Details

#renderObject



10
11
12
13
14
# File 'lib/lm_docstache/renderer.rb', line 10

def render
  find_and_expand_blocks
  replace_tags(@content, @data)
  return @content
end

#render_replace(text) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/lm_docstache/renderer.rb', line 16

def render_replace(text)
  @content.css('w|t').each do |text_el|
    rendered_string = text_el.text
    if !(results = rendered_string.scan(/\|-Lawmatics Test-\|/)).empty?
      text_el.content = text
    end
  end
  return @content
end