Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi there,
I can't seem to find a function in Template::Toolkit that will do a simple uri unescaping. Is there one? I see one for escaping though:
<code> uri %

thanks a lot

Replies are listed 'Best First'.
Re: Template::Toolkit uri unescape
by Your Mother (Archbishop) on Jun 08, 2009 at 18:33 UTC

    You can create your own filters (pass it to the config part of the template object). Untested (I haven't written a filter in awhile) but if it's not right, it's close-

    use URI::Escape (); FILTERS => { uri_unescape => sub { URI::Escape::uri_unescape(@_); }, }, ---- Then in the template: [% my_uri_string | uri_unescape %].

    It seems a bit strange to have an unescaped URI given to the template though. Probably there is something in the backend which is not being handled as well as it could be.

      Thank you! That works!
Re: Template::Toolkit uri unescape
by Anonymous Monk on Jun 08, 2009 at 18:02 UTC
    sorry I meant:  [% var | uri %]