[Nitro] Elements and Partials

Robert Mela rob at robmela.com
Mon Sep 17 10:00:16 EDT 2007

What do people think about the comparison of Nitro elements to Rails 

It occurs to me that Elements are at once both more flexible and simpler.

1) For starters, a partial has only one point of inclusion in a 
template.   You can pass parameters to it, which is clumsy for some 
areas.   So "render _footer" is the same across all pages -- there's not 
much flexibility in wrapping custom footer content in it.

With Elements, there are two points of inclusion -- a begin and an end, 
and all the stuff in between is passed to the Element as "content".

2) It also occurs to me that Elements allow stripping the HTML mess out 
of templates -- making for cleaner, more maintainable templates. while 
at the same time keeping relevent content in the same template.  For 
some reason I don't quite see this with Rails partials.

One of the things I hate most is having to match endless nested divs and 
pre's.   Templates allow putting divs into elements.   The elements can 
be named according to their semantic usage, the resulting template is 
MUCH easier to read and work with.  Matching the opening and closing 
tags is already handled within the Element -- that alone is worth a lot 
to me.

For example, this element:

class CodeSnippet
   def render
         <pre class='codesnipped'>

... included in the template is...

   def say_hello(msg)
     puts msg

... which, in a template full of content is MUCH MUCH easier to identify 

<pre class='codesnippet>
   def say_hello(msg)
     puts msg

-------------- next part --------------
A non-text attachment was scrubbed...
Name: rob.vcf
Type: text/x-vcard
Size: 116 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/nitro-general/attachments/20070917/620f33af/attachment-0001.vcf 

More information about the Nitro-general mailing list