On Fri, 26 Apr 2002, Tatsuhiko Miyagawa wrote:
> Ah, completely missed that. Sorry for the duplicate effort. I just
> uploaded Inline::TT onto CPAN few minutes ago. Maybe we should co-work
> for it now.
Yeah, sounds like a good idea. It's not like I didn't stamp all over
Andy's toes with Template::Filter::Plugin last month (yes, I know I said
I'd make some patches for my functionality in his code....I'm still
investigating the pros and cons.)
> # And Inline::TT should be named Inline::Template? but IMO
> # 'Inline::Template' is too generic (it reminds me of another usage),
> # despite the fact that TT itself is named 'use Template;' ;)
Whatever. Doesn't really matter. I was picking "Template" because that's
what the Template Toolkit was called on CPAN. However, a rose by another
name and all that...
> I use include() of TT, which localizes variables magically, if I
> understand Andy's code correctly ;)
Yes, yes it does. Which is half the problem. ;-)
> ok 1 - parameter passing
> ok 2 - stash localisation
> not ok 3 - variable passing
> # Failed test (- at line 10)
> # got: '1'
> # expected: '2'
> 1..3
> # Looks like you failed 1 tests of 3.
The value of "n" the in the counter BLOCK is being restored to the value
it had before the block was entered by the delocalisation process. Not
that useful for counting things.
The trouble is that you have the dilemma of calling a template with an
INCLUDE (which will allow you to restore variables to their original
value, but not allow you to maintain state between calls) or PROCESS
(which will not localise varibles but will allow the template to therefore
keep count of things, etc.) In TT proper you can call a block either way,
but you only have one way to call the block with Inline - by calling the
function that has the same name as the block.
My solution was to manually get from the stash any varibles that we're
passing in, remember their values, call the block, and then set all the
varibles back to what they originally were. This way the stash can be
changed between calls to the inlined blocks, but the varibles you pass in
exist only for the duration of that call. It's the best attempt at DWIM I
could get.
Hope that helps.
Later.
Mark.
--
s'' Mark Fowler London.pm Bath.pm
http://www.twoshortplanks.com/ [EMAIL PROTECTED]
';use Term'Cap;$t=Tgetent Term'Cap{};print$t->Tputs(cl);for$w(split/ +/
){for(0..30){$|=print$t->Tgoto(cm,$_,$y)." $w";select$k,$k,$k,.03}$y+=2}