Skip to content

Instantly share code, notes, and snippets.

@mbklein
Created March 7, 2011 18:24
Show Gist options
  • Save mbklein/858923 to your computer and use it in GitHub Desktop.
Save mbklein/858923 to your computer and use it in GitHub Desktop.
xmlr = XmlRegistry.new
xmlr.template(:person) do |xml,name,title|
xml.person :title => title, name
end
doc = Nokogiri::XML('<people/>')
doc.root.add_child(xmlr.person('Jeff Lebowski','The Dude'))
doc.to_xml
=> "<people><person title=\"The Dude\">Jeff Lebowski</person></people>"
xmlr = XmlRegistry.new({ "mods" => "http://www.loc.gov/mods/v3" })
xmlr.template(:title) do |xml|
xml[:mods].titleInfo(...)
end
doc.insert_template([*term_pointer], template_name, *template_args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment