This queue is for tickets about the HTML-Template-Pluggable CPAN distribution.

Report information
The Basics
Id:
30767
Status:
open
Priority:
Low/Low

People
Owner:
Nobody in particular
Requestors:
clee [...] genmeta.com
Cc:
AdminCc:

BugTracker
Severity:
Important
Broken in:
0.17
Fixed in:
(no value)



Subject: Dot plugin: loop vars as arguments to method calls
At present, I am unable to use a loop variable in a method call. By this I mean, for example: <tmpl_loop artist.cds> <tmpl_var Formatter.format_currency('US', this.price)> </tmpl_loop> With the above, HTML::Template::Plugin::Dot fails to recognize this.price as a valid TMPL_VAR. Also, probably related, is the inability to use loop context vars in a similar scenario. For example: <tmpl_loop artist.cds> <tmpl_var Formatter.sprintf('%04d', __counter__)> </tmpl_loop> Again, HTML::Template::Plugin::Dot fails to recognize __counter__ as a valid TMPL_VAR.
Subject: Re: [rt.cpan.org #30767] Dot plugin: loop vars as arguments to method calls
Date: Tue, 20 Nov 2007 16:30:18 +0100
To: bug-HTML-Template-Pluggable@rt.cpan.org
From: Rhesa Rozendaal <rhesa@cpan.org>
Cliff Lee via RT wrote:
Show quoted text
> > At present, I am unable to use a loop variable in a method call. By this > I mean, for example: > > <tmpl_loop artist.cds> > <tmpl_var Formatter.format_currency('US', this.price)> > </tmpl_loop> > > With the above, HTML::Template::Plugin::Dot fails to recognize > this.price as a valid TMPL_VAR.
Try writing that as <tmpl_loop artist.cds> <tmpl_var name="Formatter.format_currency('US', this.price)"> </tmpl_loop> HTML::Template itself tokenises tmpl_var tags much like HTML itself, so you have to protect spaces by quoting the constructs.
Show quoted text
> Also, probably related, is the inability to use loop context vars in a > similar scenario. For example: > > <tmpl_loop artist.cds> > <tmpl_var Formatter.sprintf('%04d', __counter__)> > </tmpl_loop> >
That would be related, but I don't recall having added explicit support for H::T's builtin vars like __counter__ or __first__. I've just added a test for it, and it does seem it's not working. I'll see if I can add support for it. However, since I'll have to do it myself (instead of relying on H::T's code for it), it might take a while. Rhesa
From: clee@genmeta.com
On Tue Nov 20 10:31:28 2007, RHESA wrote:
Show quoted text
> Cliff Lee via RT wrote:
> > > > At present, I am unable to use a loop variable in a method call. By
> this
> > I mean, for example: > > > > <tmpl_loop artist.cds> > > <tmpl_var Formatter.format_currency('US', this.price)> > > </tmpl_loop> > > > > With the above, HTML::Template::Plugin::Dot fails to recognize > > this.price as a valid TMPL_VAR.
> > Try writing that as > > <tmpl_loop artist.cds> > <tmpl_var name="Formatter.format_currency('US', this.price)"> > </tmpl_loop> > > HTML::Template itself tokenises tmpl_var tags much like HTML itself, > so you > have to protect spaces by quoting the constructs.
Sorry, in an effort to contrive a simplified example for illustration purposes, I ended up basing my example above on the examples in the ::Dot documentation, which excludes the quoting. In fact, the problem is present even when quoting the constructs. Cliff


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.