APM: Framework help: Can HTML::Template do this? If not, what CPAN module can?

Bill Raty bill.raty at gmail.com
Fri Sep 9 12:12:59 PDT 2005


I've found another interesting inflection point is the 'associate' parameter 
given to the template constructor. Associate tells the template that another 
object has a 'param' method that acts like the one in CGI.pm: called with 
args its a setter, called without args in a list context returns a list of 
parameter names that are provided by the object. Thus the code using the 
template can do some passive relection of templates by making a crafty 
'param' method.

I'll send out examples if I'm able to cobble up anything promising.

Meanwhile, thanks again Austin Mongers!

-Bill

On 9/8/05, Bill Raty <bill.raty at gmail.com> wrote:
> 
> Thanks Wayne.
> 
> Aha! I may get away with it using the 'filters'. Also the special loop 
> vars look promising:
> 
> 
> <TMPL_LOOP NAME="FOO">
>       <TMPL_IF NAME="__first__">
>         This only outputs on the first pass.
>       </TMPL_IF>
> 
>       <TMPL_IF NAME="__odd__">
> 
>         This outputs every other pass, on the odd passes.
>       </TMPL_IF>
> 
>       <TMPL_UNLESS NAME="__odd__">
>         This outputs every other pass, on the even passes.
>       </TMPL_IF>
> 
> 
>       <TMPL_IF NAME="__inner__">
>         This outputs on passes that are neither first nor last.
>       </TMPL_IF>
> 
>       This is pass number <TMPL_VAR NAME="__counter__">.
> 
> 
>       <TMPL_IF NAME="__last__">
>         This only outputs on the last pass.
>       <TMPL_IF>
> 
> 
>    </TMPL_LOOP>
> 
> 
> It still seems to require that the template writer to know too much about 
> inclusions or adhere to a convention.
> 
> -Bill
> 
> 
> 
> 
> 
> 
> On 9/8/05, Wayne Walker <wwalker at bybent.com> wrote:
> > 
> > You can do this with TMPL_IF and TMPL_INCLUDE
> > <head>
> > <tmpl_if name=calendar_present>
> > <tmpl_include name="path/to/cal.js">
> > </tmpl_if>
> > </head>
> > <body>
> > stuff
> > <tmpl_if name=calendar_present>
> > <div .....>
> > </tmpl_if>
> > </body>
> > 
> > This requires that you set calendar_present=1 in the calling program.
> > 
> > Since I'm not sure what decides if the calendar ends up in the 
> > container, I can't guess further
> > 
> > 
> > On Thu, Sep 08, 2005 at 04:58:52PM -0500, Bill Raty wrote:
> > >
> > > I'm trying not to reinvent the wheel, but I'm having difficulty 
> > determining
> > > if the wheel I'm needing has been invented. 
> > >
> > > I've looked at HTML::Template POD, and I get the basic concept. In my
> > > ignorance I'm failing to see how I can apply it to my problem, and 
> > ifthere
> > > are other CPAN modules that are better suited to my task. 
> > >
> > > I want to have a DWIMy page component system so that page controls can 
> > be
> > > called out and "Do The Right Thing". Example:
> > >
> > > I have a calendar input widget set that requires pieces of HTML,
> > > JavaScript, and CSS, which need to be exposed in the container page; a
> > > script tag in the "head", a 'div' that needs to appear early on inside 
> > the
> > > "body" tag, and the 'input' tag that has event handlers that usethe 
> > earlier 
> > > script tag.
> > > I'd like a system that abstract the container page, that lets me 
> > develop the
> > > calendar control component as if it were the containing page, but when
> > > added/included/embedded in the container page the system smartly 
> > places the 
> > > control component elements in the correct part of the containing page. 
> > The
> > > clincher is the second add of the calendar widget doesn't duplicate 
> > the
> > > 'script' and 'div' tags, but only interjects the 'input' tag for the 
> > second 
> > > control.
> > 
> > > _______________________________________________
> > > Austin mailing list
> > > Austin at pm.org
> > > http://mail.pm.org/mailman/listinfo/austin
> > 
> > --
> > 
> > Wayne Walker
> > 
> > wwalker at bybent.com Do you use Linux?!
> > http://www.bybent.com Get Counted! http://counter.li.org/
> > Perl - http://www.perl.org/ Perl User Groups - http://www.pm.org/ 
> > Jabber: wwalker at jabber.gnumber.com AIM: lwwalkerbybent
> > IRC: wwalker on freenode.net <http://freenode.net>
> > _______________________________________________ 
> > Austin mailing list
> > Austin at pm.org
> > http://mail.pm.org/mailman/listinfo/austin
> > 
> 
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/austin/attachments/20050909/1b7c7743/attachment.html


More information about the Austin mailing list