A first glance, there are three approaches to generating pages that have specific boxes checked.
or one has to temporarily break the HTML in the template by doing$template->param(foo_input => "<input type=checkbox name='foo'" . $foo_checked ? " checked>" : + ">"); ... <TMPL_VAR foo_input>
or one has to bloat the template with conditional logic$template->PARAM(foo_checked => $foo_checked); ... <input type=checkbox name="foo" <TMPL_IF foo_checked>checked</TMPL_I +F>>
All of these approaches work, but none allow the unexpanded template to be viewed in a browser. In the first scheme you get an empty hole, the second scheme results in invalid HTML, and the third scheme shows each input control twice.$template->param(foo_checked => $foo_checked); ... <TMPL_IF foo_checked> <input type=checkbox name="foo" checked> </TMPL_ELSE> <input type=checkbox name="foo"> </TMPL_IF>
I didn't find a clean scheme, but did settle on a hybrid one that works.
When the initial page design is templatized,
gets turned into<input type=checkbox name="foo">
with $template->param(false => 0); When viewed in a browser, the original input tag is displayed. But when the template is expanded, the tag in the template gets discarded and a dynamically generated tag takes its place.<TMPL_IF false><input type=checkbox name="foo"></TMPL_IF><TMPL_VAR f +oo_input>
The downsides of this scheme are that HTML is being produced in code, and that template designers need to coordinate changes with the application developers (which is true anyway). But it works, and it also works when generating dynamic pop-up menus using select tags.
If anyone has a better approach, I would love to hear about it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Browser-viewable HTML::Template templates
by cLive ;-) (Prior) on Jan 12, 2003 at 08:50 UTC | |
by Aristotle (Chancellor) on Jan 12, 2003 at 14:48 UTC | |
by dws (Chancellor) on Jan 12, 2003 at 17:51 UTC | |
|
Re: Browser-viewable HTML::Template templates
by Aristotle (Chancellor) on Jan 12, 2003 at 02:43 UTC | |
|
Re: Browser-viewable HTML::Template templates
by Anonymous Monk on Jan 12, 2003 at 16:41 UTC | |
|
Re: Browser-viewable HTML::Template templates
by Anonymous Monk on Jan 14, 2003 at 23:35 UTC |