On Fri, Oct 06, 2006 at 01:55:36PM -0700, Randal L. Schwartz wrote:
> >>>>> "Bill" == Bill Moseley <[EMAIL PROTECTED]> writes:
> 
> Bill> The TT docs for the uri filter suggests:
> Bill>     <a href="[% filename | uri | html %]">click here</a>
> 
> Bill> Which I have done for a while out of habit, but doesn't work well for
> Bill> fragments:
> 
> Bill> $ perl -MTemplate -le 'Template->new->process( \"[% u | uri | html %]", 
> { u => "my file&stuff.html#offset" } )' 
> Bill> my%20file&amp;stuff.html%23offset
> 
> Correct.  But you had a *file* named "my file&stuff.html#offset",
> it's doing *precisely* the right thing.

It's bad enough having a resource named "my file&stuff.html", so let's
not get carried away. ;)


> Not sure why you thought you should escape the fragment, but oh
> well.

Let's say you have a macro "link".  Which way would you write it?


    MACRO link( path, text ) BLOCK;
        "<a href='$path'>$text</a>";
    END;

Or as suggested in the docs:

    MACRO link( path, text ) BLOCK;
        p = path | uri | html;
        t = text | html;
        "<a href='$p'>$t</a>";
    END;

Using URI is a better way, of course, and with catalyst it's:

    MACRO link( path, text ) BLOCK;
        p = c.uri_for( path );
        t = text | html;
        "<a href='$p'>$t</a>";
    END;

-- 
Bill Moseley
[EMAIL PROTECTED]


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

Reply via email to