[Templates] The uri filter and fragments

Josh Rosenbaum josh@infogears.com
Fri, 06 Oct 2006 12:46:28 -0600


Bill Moseley wrote:
> The TT docs for the uri filter suggests:
> 
>     <a href="[% filename | uri | html %]">click here</a>
> 
> Which I have done for a while out of habit, but doesn't work well for
> fragments:
> 
> $ perl -MTemplate -le 'Template->new->process( \"[% u | uri | html %]", { u => "my file&stuff.html#offset" } )' 
> my%20file&amp;stuff.html%23offset
> 
> Frankly, I'm not sure what's should happen, but the browsers I tested
> with choked on it.
> 
> I'm now using Catalyst, so I use its c.uri_for(), but one usage of
> that filter still ended up in a macro and broke some links.

Why not just do?:
<a href="[% filename | uri | html %]#offset">click here</a>

-- Josh