> 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
%{
<h1>\#{#{myob}.name}</h1>
}
end
end
<Calendar myob="ob_instance" />
I know this is not elegant but it works with the current element
infrastructure.
> = Is it possible to add javascript include in the page's header from the
> element ?
Have a look at
lib/nitro/helper/javascript/prototype.rb
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.
regards,
Geogre.
--
http://www.gmosx.comhttp://www.navel.grhttp://www.nitrohq.com