[Petal] Creating a mailto href tag

Jean-Michel Hiver jhiver@mkdoc.com
Fri, 26 Jul 2002 14:42:37 +0100


> that would work even better (one less variable to pass to the template). Granted, I 
> realize that modifiers are not part of the TAL spec but hey we've already crossed 
> that line <g>. I'm seeing something like the following:
> 
>   <a petal:attr="href :cat 'mailto:' email">someone@foo.com</a>
> 
> I'm not sure I can pass a modifier as the second argument in a petal:attr tag, 
> though.

Yes you can pass a modifier, I guess I need to document the internals a
bit better... I suppose an even better thing to do would be to write a
supra-dupra clean expression evaluation engine, which I plan to do so
that we can support nested modifiers...

I'm always open to suggestions! At the moment, the syntax is the
following:

:modifier [expression]

And it's entirely up to :modifier to resolve the expression...

Yes, that means you *could* write a modifier that'd let you do:

<?petal:var name=":perl 2*(3+5)-2"?>

But I think it'd be really *BAD*!


> > Is going to make a lot of WYSIWYG editors very upset. But in this case you
> > can be saved by the magical dollar :+) So what I'd do would be:
> 
> Yeah, I suspect you're right about that syntax making the GUI editors unhappy. 
> However, I really don't like the idea of using plain Perl variables in my templates; I 
> can't put my finger on it, but something bothers me about it. If the above wouldn't 
> work, I'd prefer to create an :href modifier tag that would would like:

Except that they are *NOT* perl variables... For example '$encode:blah'

Is internally 'canonicalized' into '<?petal:var name=":encode blah"?>'

Which later on is turned into 'push @res, $hash->{':encode blah'};'

$hash being a tied object, the module Petal::Hash::Encode_XML is called,
with the string 'blah'... that's about it for the internals :-)


>   <a petal:attr=":href email" petal:content="email">someone@foo.com</a>
> I guess that'll be my first contribution to the codebase (besides debugging).

Cool, but then *MAYBE* this modifier should be called :mailto rather
than :href... and you'd use it as follows:

<a petal:attr="href :mailto email" petal:content="email">someone@foo.com</a>


Indeed, alternatively you could write: $mailto:email,

Or even <?petal:var name=":mailto email"?> :-)


Cheers,
-- 
IT'S TIME FOR A DIFFERENT KIND OF WEB
================================================================
  Jean-Michel Hiver - Software Director
  jhiver@mkdoc.com
  +44 (0)114 255 8097
================================================================
                                      VISIT HTTP://WWW.MKDOC.COM