module SolrEad::Formatting

Constants

RENDER_ATTRS

Public Instance Methods

ead_to_html(xml) click to toggle source

Use this method convert the xml directly

# File lib/solr_ead/formatting.rb, line 32
def ead_to_html xml
  ::Sanitize.clean(transform_render_attributes(xml), :elements => RENDER_ATTRS.values.uniq )
end
term_to_html(term) click to toggle source

If you're within the context of an OM::XML::Document, you can just pass the term you want converted and this will get the xml using the term.

# File lib/solr_ead/formatting.rb, line 27
def term_to_html term
  ead_to_html self.send(term).nodeset.to_xml
end

Private Instance Methods

convert_ead_tag_to_html(node) click to toggle source
# File lib/solr_ead/formatting.rb, line 49
def convert_ead_tag_to_html node
  if RENDER_ATTRS.keys.include? node["render"]
    node.name = RENDER_ATTRS[node["render"]]
    node.remove_attribute "render"
  end
end
transform_render_attributes(xml) click to toggle source
# File lib/solr_ead/formatting.rb, line 38
def transform_render_attributes xml
  ::Sanitize.clean(xml, :transformers => transformer)
end
transformer() click to toggle source
# File lib/solr_ead/formatting.rb, line 42
def transformer
  lambda do |env|
    convert_ead_tag_to_html(env[:node])
    {:node_whitelist => [env[:node]]}
  end
end