--- title: Webgen::ContentProcessor::Builder --- ## Description This content processor can be used to programatically create XHTML/XML documents ([Reference][1]). The top builder object is provided through the `xml` object. There are also other objects provided by webgen available - have a look at the [erb documentation]({relocatable: erb.html}). > This extension is only available if you have installed the [builder][1] library. The preferred way > to do this is via Rubygems: > > gem install builder {.exclamation} ## Examples Here is a short sample of content that is valid Ruby and uses the special `xml` object: xml.h1("This a h1 header", :id => 'myid') xml.p do |p| p.text! "You can just write " p.b "your" p.text! "paragraphs here and" p.a("link", :href => "http://someurl.com") p.text! "them below. This is also a" p.i "nice" p.text! "format!" end xml.blockquote(:class => 'information') do |bq| bq.text! "Citations are easy too." bq.text! "Really. And you can assign them attributes." end xml.ul do |ul| ul.li "Lists" ul.li "aren't" ul.li "difficult" ul.li "either." end Following is a complete example which shows how to use this extension in a page file which generates a custom XML document (the `content` block has to be valid Ruby!): --- output_path_style: [:parent, :cnbase, ['.', :lang], '.xml'] title: Person Object template: ~ --- pipeline:builder xml.persons(:path => node.absolute_lcn) do |p| p.person do |b| b.firstname('Thomas') b.lastname('Leitner') end p.person do |b| b.firstname('Other first') b.lastname('Other last') end end The above will produce the following output: Thomas Leitner Other first Other last [1]: http://builder.rubyforge.org "Homepage of builder library"