lib/docx/builder.rb in docx-builder-0.1.11 vs lib/docx/builder.rb in docx-builder-0.1.13

- old
+ new

@@ -12,17 +12,22 @@ module Docx module Builder class Error < StandardError; end class Template - SECTIONS = %w( word/header1.xml word/document.xml ) - + def initialize(path) @document = Docx::Decoder.to_xml(path) + @sections = ["word/document.xml"] + @document.each do |file| + if file.name.include? "word/header" + @sections.push(file.name) + end + end end def render(data) - SECTIONS.map do |section| + @sections.map do |section| cleaned_document = clean(@document.read(section)) erb_template = build_erb_template(cleaned_document) processed_document = render_erb_template(erb_template, data) [section, processed_document] end.to_h