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:
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.
Comments, anyone?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
Jeff
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
-sam
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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:
Before:
<img tmpl_attr="attribute=src escape=url name=img_url"
tmpl_attr="width name=img_width"
tmpl_attr="attribute=height img_height">
After:
<img src="<TMPL_VAR escape=url name=img_url>"
width="<TMPL_VAR name=img_width>"
height="<TMPL_VAR img_height>">
(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.
Comments, anyone?
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 .
Jeff
"HTML::Template, wassssssssup?"
"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?
-sam
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.
Jeff
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.
-sam
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!
-sam
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.
-sam