[Petal] Modifiers and variables

William McKee william at knowmad.com
Mon Aug 16 18:58:08 BST 2004


Hey Fergal,

Good to hear from you.


> Last year when I was hacking Petal, I changed the modifier code so that it
> examined the modifier at runtime to see if it was new style or old style.
> For an old style modifier it just passed in the whole string to the process()
> method as usual. If it was new style, it parsed the string a set of function
> arguments and passed them to the new_process method.

So you've been down this road too.


> This allowed me to do
> 
> mod:this/that "some string"
> 
> (I think that'sargument syntax, it's been a while)

If that's inside of an attribute, you'd need to use single quotes or
escape those double quotes.


> Looking at the current code in Petal/Hash.pm

<snip>

> just changing that last line to
> 
> 		if ($module->can("new_process")

Ahh, so this is how you differentiate between new style and old style
modifiers.


> 		{
> 		    # parse_args() is not correct but you get the idea
>         my @args = parse_args($key); 

Could we draw this in from the work you did? I tried to find where you
did that in Petal::CodePerl but couldn't find a parse_args sub. I'm
guessing you used a different name or didn't extract the code into a
subroutine. Could you give me a pointer?


> would mean that no one has to parse TALES expressions in their modifiers,
> Petal would do it itself and you could then do arbitrarily complex stuff in
> the arguments to modifiers,
> 
> truncate:big/long/string max/string/length

If I understand you correctly, this sounds great. Is TALES where
modifiers and the like are defined? I get TAL/TALES/METAL confused. I
think that the proposed subroutine would do that. Nonetheless, I'd like
to see your example (with the exception that the TALES expression cannot
contain numbers).


Thanks,
William

-- 
Knowmad Services Inc.
http://www.knowmad.com


More information about the Petal mailing list