[Nitro] Questions on Element, Control and rendering

George Moschovitis george.moschovitis at gmail.com
Wed Jan 18 08:50:54 EST 2006

> As an example, I want to code a generic calendar that I can use
> everywhere I need/want.

funny, i was working on this too ;-)

forget about controls at the moment. What you need are elements.
Controls are used by the scaffolder. However I was thinking about
renameing the scaffolder controls to PropertyControl or something, and
have Control as an alias to element when used to implement ...controls

> = What is the difference between an Element and a Control ?
> Elements are transformed by the renderer. They have a notion of childs
> and parent.
> Controls are used by the form helper. They only represent a value.

Yeah. Please note that Elements are statically resolved when compiling
a template. They are a form of template macro.

> = Can't these two classes be merged in one or are they too different ?
> For me, elements are bit like actions outside a class. It's a bit like
> HMVC where you have subcontrollers.

As I said, I am thinking on this. I think the name control for the
form helper widgets is a bit unfortunate. Any other opinions on this?

> = Is it possible to pass ruby objects to an Element instead of strings ?

Dont forget that Elements are just transformers of code. here is an
example element:

class Calendar
  def render

<Calendar myob="ob_instance" />

I know this is not elegant but it works with the current element

> = Is it possible to add javascript include in the page's header from the
> element ?

Have a look at


In general your calendar should be implemented as a helper. Ie you use
helper for such kind of run-time ...helpers and elements for compile
time template transformations.


More information about the Nitro-general mailing list