Partials every-where

March 3, 2010 at 11:57 am (Partials) (, , , )

Hi everybody,

Partials are not limited to be used for HTML rendering.

They can be used for XML too.

Here is an example file ( _details.builder )
xml.name user.name
xml.gender user.gender
xml.age user.age

This can be used in another regular builder file as follows:
xml.instruct! : xml, :version=>”1.0″
xml.users {
for user in users
xml <“users/details” , :locals=>{:user=>user})
end
}

Hope, this comes handy 🙂

Advertisements

Permalink 1 Comment