Hi,
I'm busy with creating a widget based web templating engine, but I have
some problems, please help me. The engine would allow you to define
widgets, and use those in your templates. I would like it to be an OO
module.
In the template, you can write this:
<server:input id="name" width="100px" maxlength="64" important="yes" />
When the template engine read it, it will call a subroutine:
call_a_sub_for_input(id=>'name', width=>'100px', maxlength=>'64',
important=>'yes');
What this sub gives back, will be put into the output. I hope, you got the
idea.
I have the code, that can parse the template, and the code, that would
call the widget, so no problems with it. I don't know, how to put it
together. I don't know, how should the programmer define a new widget,
how it would be the most nicer way? How it can be detected by the template
engine? I don't want a register function, like this:
$wte = new WTE;
$wte.register('input', &my_input_widget);
I don't prefer it, to be 20-30 register line in my programs, that does
nothing, just register.
It would be OK, to just define a global subroutine, and allow the template
engine to call widget_$name if it reads a widget, but...
sub widget_input(*%params) {
...
}
It's not nice. Maybe something like this?
new_widget :input => {
return "<input />";
}
It's almost a register function, but it's more compact, and I like it. But
if I would like to get parameters from the widget caller, how can I manage
it? Is it possible to call this new noname sub with parameters, and get it
easily inside the sub, for example like this:?
new_widget :input => {
my $name = _something_{'id'};
return '<input name="' ~ $name ~ '" />';
}
And I have more questions, but that's enough for this mail. Did you got my
problem?
Bye,
Andras