Class: LMDocstache::Renderer
- Inherits:
-
Object
- Object
- LMDocstache::Renderer
- Defined in:
- lib/lm_docstache/renderer.rb
Constant Summary collapse
- BLOCK_REGEX =
/\{\{([\#\^])([\w\.]+)(?:(\s(?:==|~=)\s?.+?))?\}\}.+?\{\{\/\k<2>\}\}/m
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
-
#initialize(xml, data, options = {}) ⇒ Renderer
constructor
A new instance of Renderer.
- #render ⇒ Object
- #render_replace(text) ⇒ Object
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, = {}) @content = xml option_types = [:special_variable_replacements, :hide_custom_tags] @parser = Parser.new(xml, data, .slice(*option_types)) end |
Instance Attribute Details
#parser ⇒ Object (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
#render ⇒ Object
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 |