Re: Modifiers and variables

Jean-Michel Hiver <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.petal
Message-ID <[email protected]>
> I'm working on adding several new modifiers to Petal::Utils and have
> come across an interesting proposal which I wanted to float with the
> list.
> 
> When processing arguments passed to a modifier, there is not yet a
> standard way of reading these values (at least to my knowledge).

How do you mean? When you write a modifier, you have access to the raw 
string that comes after the modifier. What you do with that string is up 
to you.

Look at Petal::Hash::String and Petal::Hash for examples.


> Warren
> S. submitted a couple of modifiers which included a subroutine that he
> devised which fetches the arguments in the following way:
> 
>   1 - if the argument is a number (decimals are OK) or contains single
>   quotes, return the argument itself (i.e., plaintext)
>   2 - otherwise use the argument as the key to the hash and return that
>   value

Interesting, maybe this behavior could be implemented in an abstract 
modifier which could be subclassed at will.


> I like this as it makes it really easy to pass in plain text without
> having to use the string: modifier. However, I'm not sure whether this
> is considered TAL compliant. What are your thoughts? I've included the
> subroutine at the end.

Well, it's not TALES (TAL Expression Syntax) compliant. However in my 
view what's inside the TAL attributes doesn't really matter since it's 
pretty much application-dependant anyway.

Petal has never been TALES compliant since it lets you pass argument to 
methods, which in my knowledge is not supported by TALES.


Cheers,
Jean-Michel.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.