I'm excited.
But I do have a syntax question. I was looking at your example (the
Headline one) and it didn't initially feel right. It seems almost like
it could be handled in a more XMLish way. Like:
Here's an example of a component that takes two arguements, the font
size and the font color for a headline:
package Component::Headline;
use base 'HTML::Template::Component';
use constant TEMPLATE_FILE => 'headline.tmpl';
sub output {
my $template = shift;
my $body = shift; #holds what was in the middle of tags
my $args = shift; # holds a hash ref of arguments in begin tag
# break out size and color from $args text
#these could actually just be passed as $template->param(%{$args});
my $size = $args->{'size'};
my $color = $args->{'color'};
$template->param(SIZE => $size,
COLOR => $color,
TITLE => $body);
return $template->output();
}
1;
And headline.tmpl, the component's template:
<H1>
<FONT SIZE="<TMPL_VAR SIZE>" COLOR="<TMPL_VAR COLOR>">
<TMPL_VAR TITLE>
</FONT>
</H1>
The user of this component uses it like this:
<TMPL_COMP NAME="Component::Headline" SIZE='1'
COLOR='red'>HTML::Template::Component Is Made Of People!</TMPL_COMP>
This seems more JSP/XML friendly but I also don't know how comfortable
people are with 'args on the fly' or even if it's possible with the
current HTML::Template. I'm sure most people don't care about JSP feel,
but I've always loved they way they handle custom tags, which is what I
see this becoming.
Of course, I could be wrong, in which case tell me to shut up.
-------------------------------
J o s e p h E r i c k s o n
P u z z l e S m i t h
EYEMG - interactive media group
190 n. union #300, akron, ohio 44304
http://www.eyemg.com
fone-330.434.7873
phax-330.253.2186
On Monday, November 19, 2001, at 12:28 PM, Sam Tregar wrote:
> On Mon, 19 Nov 2001, Mike Futerko wrote:
>
>> I have got an idea to implement one more TAG into template language
>> named TMPL_EXEC. For example <TMPL_EXEC NAME="SomeModule"> will execute
>> SomeModule.pm file and output of them put instead of this TAG. In this
>> case
>> SomeModule.pm must cover some API for TMPL_EXEC TAG. For example
>> SomeModule.pm
>> must have at least two methods new, and output.
>
> I had an idea similar to this a while back - I called it
> HTML::Template::Component. I got as far as writing the docs but I never
> wrote any code. It could probably be implemented using filters much
> like
> HTML::Template::Expr.
>
> I've attached the docs - take a look and see what you think.
>
> -sam
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]