On Sat, 17 Feb 2007, Trans wrote:

>>
>> So simple!  The XML namespace example should have clued me in -- need
>> more coffee.
>>
>> As Tim Becker mentioned, this is a lot like Markaby, but it fixes some
>> of Markaby's shortcomings -- mainly support for valid XML tag
>> characters not currently allowed in method_missing and/or symbols.
>
> markaby has #tag! which is same as #_ however (AFAICT) markaby does
> html, not xml.
>
> the builder pattern is pretty common now. Facets has a class one can
> use to build any kind you'd like called BuildingBlock. you simply
> apply a helper object for specially defined "tags" and the method to
> use as the default. Very basic example:
>
>  require 'facets/more/buildingblock'
>
>  module BasicXMLMarkup
>    extend self
>
>    def element( tag, body=nil, atts={} )
>      atts = atts.collect{ |k,v| %{ #{k}="#{v}"} }.join('')
>      if body
>        "<#{tag}#{atts}>#{body}</#{tag}>"
>      else
>        "<#{tag}#{atts} />"
>      end
>    end
>  end
>
>  builder = BuildingBlock.new(BasicXMLMarkup, :element)
>
>  builder.html do
>    h1 "Hello World", :class=>"big"
>  end
>
> produces
>
>  "<html><h1 class=\"big\">Hello World</h1></html>"

right, but with that approach, or that of markaby, tags like 'p', 'id',
'size', et all are clobbered.  with builder they've solved this by making the
user pass the builder to all blocks, but that's a lot of typing!


-a
-- 
we can deny everything, except that we have the possibility of being better.
simply reflect on that.
- the dalai lama