Class: TemplateExpander
- Defined in:
- lib/notroff/template_expander.rb
Constant Summary collapse
- PATH =
'/office:document-content/office:body/office:text'
- TEMPLATE =
File.('../content.xml', __FILE__)
Instance Method Summary collapse
-
#initialize ⇒ TemplateExpander
constructor
A new instance of TemplateExpander.
- #insert_body(doc, body_elements) ⇒ Object
- #process(content_map) ⇒ Object
Constructor Details
#initialize ⇒ TemplateExpander
Returns a new instance of TemplateExpander.
9 10 |
# File 'lib/notroff/template_expander.rb', line 9 def initialize end |
Instance Method Details
#insert_body(doc, body_elements) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/notroff/template_expander.rb', line 18 def insert_body(doc, body_elements) text_element = REXML::XPath.first(doc, PATH) n = text_element.elements.size n.times {|i| text_element.delete_element(1)} body_elements.each {|el| text_element.add_element(el)} doc end |
#process(content_map) ⇒ Object
12 13 14 15 16 |
# File 'lib/notroff/template_expander.rb', line 12 def process( content_map ) doc = REXML::Document.new(File.new(TEMPLATE)) insert_body(doc, content_map[:body]) doc.to_s end |