Class: Sablon::Parser::MailMerge

Inherits:
Object
  • Object
show all
Defined in:
lib/sablon/parser/mail_merge.rb

Defined Under Namespace

Classes: ComplexField, MergeField, SimpleField

Instance Method Summary collapse

Instance Method Details

#parse_fields(xml) ⇒ Object



132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/sablon/parser/mail_merge.rb', line 132

def parse_fields(xml)
  fields = []
  xml.traverse do |node|
    if node.name == "fldSimple"
      field = SimpleField.new(node)
    elsif node.name == "fldChar" && node["w:fldCharType"] == "begin"
      field = build_complex_field(node)
    end
    fields << field if field && field.valid?
  end
  fields
end