Like others in this group, I have some philosophical qualms regarding the invalid HTML sytnax produced using TMPL_VAR in HTML attributes, i.e:
<img src="<TMPL_ATTRIBUTE NAME=param>">
Coming from an intense infatuation with Zope PageTemplates and the associated Template Attribute Language, I propose adding a TMPL_ATTR expression that would serve as an alias for TMPL_VAR in HTML attributes. The syntax would be as follows:
<img TMPL_ATTR="ATTRIBUTE=src NAME=img_url">
The 'ATTRIBUTE=' would be optional, all other parameters would be identical to those used by TMPL_VAR. The TMPL_ATTR expression would be processed in HTML::Template::_parse after the Vanguard compatability mode hack using a regex that converts this into the standard TMPL_VAR syntax. I have written such a regex that yields the following results:
<img tmpl_attr="attribute=src escape=url name=img_url"
<img src="<TMPL_VAR escape=url name=img_url>"
(Pardon any line wrapping)
I am currently testing a patch that implements this functionality. The patch includes a 'new_style_attributes' parameter for HTML::Template->new that optionally enables TMPL_ATTR processing.
Oops, I meant
<img src="<TMPL_VAR NAME=param>">
in the OP, line 4.
Sounds good, but I think HTML::Templates has several disadvantages if compared with other template libraries, not one. Maybe it's time to write it again from scratch, saving old syntax as-is where possible?
For example I think we should separate template parsing from modperl-specific code.
Why reinvent the wheel? Use something like Template Toolkit if you need more capabilities than what HTML::Template offers.
There are too many template libraries in the NET and it's impossible to find the right one :((((
Template Toolkit is the right one. www.template-toolkit.org .
"HTML::Template - you've got the right one, baby."
"HTML::Template - it's what's for dinner."
Maybe I should hire an advertising firm? Or maybe you should take your advertising someplace more appropriate?
I only mentioned it when the suggestion to rewrite HTML::Template from scratch arose. Such development energies would be better focused on adding features such as shared-memory template caching to TT, which has kind of become the de-facto templating library for perl. This doesn't mean that there isn't a place for lightweight libraries such as HTML::Template just that future substantial development energies would be more beneficial to the perl community if directed to the appropriate resource.
What mod_perl specific code are you talking about? Caching isn't mod_perl specific at all - it just happens to be a popular use case. Both the file cache and the shared memory cache work with normal CGI.
Really? How can I enable template caching under normal CGI? Does caching help a lot?
my $template = HTML::Template->new(filename => 'foo.tmpl', file_cache => 1, file_cache_dir => '/tmp');
Both file_cache and shared_cache work with normal CGI. Read the documentation for more details!
Sounds like a good idea for a filter! I doubt I'd put it in the main module but I'd be happy to see it as an add-on module ala HTML::Template::Expr.
Why don't you join the mailing-list and post about it there? We've been discussing how to make combining add-on modules easier.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.