On 12/16/05, Andy Wardley <[EMAIL PROTECTED]> wrote:
Josh Rosenbaum <[EMAIL PROTECTED]> wrote:
> You can also use this probably: a.match("(?i)^$b\$")

Phil Mitchell wrote:
> I'm pretty sure that tt2 doesn't do variable interpolation in match().

It does, as this simple test illustrates:

[EMAIL PROTECTED]:~] tpage
[% foo = 'hello';
   bar = 'HELLO';
   foo.match("(?i)^$bar\$") ? 'match' : 'no match'
%]
^D
match

tpage is great for quickly testing syntax issues like that.

I did test before making my rash statement ... but with *single* quotes around the RE -- heh. Thanks for the tip about tpage. 

> The question that I'm stuck with is why my macro works when the test
> is in the same template where it's defined, and doesn't work from
> another template.

Perhaps you need to PROCESS the macros.tt template, not INCLUDE it.
PROCESS exports all variables/macros/blocks defined to the caller,
INCLUDE doesn't.

Yes, I did PROCESS my macros.tt, but it was inside header.tt, which got INCLUDED. Changing the outer inclusion to PROCESS solved. I'm coming to the conclusion that I should PROCESS everything, and leave INCLUDE for optimization time ...
 
Thanks a lot, Andy! This is my first project with tt2 and my appreciation for it grows the longer I use it.

--phil

HTH
A




--
==========================
2People Blog: http://2-people.blogspot.com/
2People site: http://www.2people.org

Reply via email to