Xml templates...

Brian Candler B.Candler at pobox.com
Wed Sep 5 03:59:22 EDT 2007


On Tue, Sep 04, 2007 at 03:37:02PM -0600, Fernand Galiana wrote:
>    Thanks Brian - Well erb sure but I still would like to get the xml
>    builder object
>    bound to the template. That's the essence of my question ie being able
>    to embed
>    erb tag within my xml template.

I think you need to choose one or the other.

(1) Do you want to write your template in XmlBuilder style?

In that case, you can't embed <% .. %>. However you don't need to, as a
builder template is just Ruby code. If you want to write "for blee in
@blees" you just write that; there's no need to encode it in Erb-style tags.

http://builder.rubyforge.org/

(2) Do you want to write your template in Erb style? In that case the
template would look something like

<blees>
  <% for blee in @blees %>
  <blee>
    <%=h blee.name %>
  </blee>
</blees>

However if you do this, and your template is called blees.erb, then until
recently Merb would send it as text/html rather than text/xml. That's what
ticket 162 is about.

Regards,

Brian.


More information about the Merb-devel mailing list