At 11:35 PM on 16 Feb 2010, Tosh Cooey wrote:

> I'd love to round out the Template Toolkit docs by including a note
> on how to properly replace the following:
> 
> [% link = someobject.url %]  (where url is say http://site.com?oops)
> [% linkText = 'Click me' %]
> [% ahref = '<a href="' _ link _ '">' _ linkText _ '</a>' %]
> [% bodyText = "Some text waiting for link insertion,  Click me" %]
> 
> [% bodyText.replace(linkText, ahref) %]
> 
> I would expect the output to be:
> 
> Some text waiting for link insertion,
> <a href="http://site.com?oops";>Click me</a>
> 
> But the ? in the url seems to be triggering pattern matching stuffs.
> 
> Is there a way around this?

Works for me. (see below)  I think your example case doesn't properly
represent the problem you're describing.  Please try again.


---cut---
cwall...@ws80:~[15:17]$ tpage > output
[% link = 'http://site.com?oops' %]
[% linkText = 'Click me' %]
[% ahref = '<a href="' _ link _ '">' _ linkText _ '</a>' %]
[% bodyText = "Some text waiting for link insertion,  Click me" %]

[% bodyText.replace(linkText, ahref) %]
cwall...@ws80:~[15:21]$ cat output





Some text waiting for link insertion,  <a
href="http://site.com?oops";>Click me</a> 
cwall...@ws80:~[15:21]$ 
---cut---


-- 

C. Chad Wallace, B.Sc.
The Lodging Company
http://www.lodgingcompany.com/
OpenPGP Public Key ID: 0x262208A0

Attachment: signature.asc
Description: PGP signature

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

Reply via email to