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 Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml, data, options = {}) ⇒ Renderer

Returns a new instance of Renderer.



7
8
9
10
11
# File 'lib/lm_docstache/renderer.rb', line 7

def initialize(xml, data, options = {})
  @content = xml
  option_types = [:special_variable_replacements, :hide_custom_tags]
  @parser = Parser.new(xml, data, options.slice(*option_types))
end

Instance Attribute Details

#parserObject (readonly)

Returns the value of attribute parser.



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

def parser
  @parser
end

Instance Method Details

#renderObject



13
14
15
16
# File 'lib/lm_docstache/renderer.rb', line 13

def render
  parser.parse_and_update_document!
  @content
end

#render_replace(text) ⇒ Object



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

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