Re: .uri() scalar vmethod?

"Felipe Gasper (cPanel)" <[email protected]> Tue, 31 Jul 2012 10:01:56 -0500
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <[email protected]>
On 7/31/12 9:56 AM, Dave Howorth wrote:
> Felipe Gasper (cPanel) wrote:
>> Any chance this could make it into a forthcoming TT release?
>>
>> our $TEXT_VMETHODS = {
>> ...
>>      dquote      => \&text_dquote,
>>      html        => \&Template::Filters::html_filter,
>>      xml         => \&Template::Filters::xml_filter,
>>      uri         => \&Template::Filters::uri_filter,
>> };
>>
>>
>> It seems like it’d be very (and conspicuously?) useful.
>
> Pardon my ignorance but what's the advantage of a vmethod over a filter
> for html, xml & uri? And isn't dquote already a vmethod?

The advantage of a vmethod over a filter is that you can more easily 
store/manipulate the result than with a filter. You can also chain 
vmethods, e.g., foo.json().html(). (I can’t see any advantage of a 
filter over a vmethod, though?)

I should clarify: dquote(), html(), and xml() are all currently vmethods 
as of TT 2.24. (I meant to clarify that in the above code, sorry!) uri() 
was not added in at that time, but I’ve not understood why. An 
environment where HTML escaping is pertinent very likely will want URI 
escaping as well.

-FG

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates