I use attributes in my template tags without using filters and without messing around with HTML::Template's internals. Here is the format I use:
<TMPL_VAR NAME="name.arg1=val1.arg2=val2"> In my perl script I use a few different routines to manage my templates. I setup most of the subroutines so that they are called when their namesake is used as a TMPL_VAR name in a template. I created a function that binds subroutines to template tags. When a tag is present in the template, the corresponding subrouting is executed with its arguments passed to it as a hash reference. Here is some code I use for this very purpose: sub parseParameters { %parameter_hash = (); my @tags = $t->param(); # Get a list of tags present in the template foreach $tag (@tags) { $tag =~ /^([^.]*)\.?(.*)?$/; # Split the tag names into 'name' and $function = $1; # 'argument' parts $parameters = $2; if(exists $tagFunctions{$function}) { # If a function exists for this tag... foreach $pair (split(/\./, $parameters)) { $pair =~ /^([^=]*)=(.*)$/; $parameter_hash{$1} = $2; # Add its parameters to a hash } my $value = $tagFunctions{$function}->(\%parameter_hash); # call the function $t->param($tag => $value); # insert the return value into the tag } } #return 1; } # This subroutine works well for loops too. sub regTags { foreach $tag (@_) { eval "\$tagFunctions{" . $tag . "} = \\&" . $tag . ";"; } } regTags(qw(remoteInclude setVar otherFunction)); parseParameters(); Using code like this has drastically improved script creation time as the only code I need to write when I create a new script is only the code that is specific to that application. This works very well for loops too. The only drawback to this method is that you would have to create your on function for including files so that you could pass your own arguments to it. I even went as far as to create a tag function that allows me to set the value of another tag function. This helps a lot for managing headers and footers, I can set the title of the page in just one spot. I believe I also created a function to do a remote include for that same reason. So that I can choose which sub-menu file I want to include into the header file from the main template file. Luke On Wed, Jun 02, 2004 at 08:55:43AM -0500, Timm Murray wrote: > I have a project which involves changing our current pages using SSI > #includes into using an HTML::Template-based solution instead. The > question of how to search these templates came up, and I've suggested using > htdig:// with a filter program that will convert the templates into text > for indexing. > > Inevitably, there will be certain pages using TMPL_INCLUDE tags. I imagine > that most of these will contain data that will not want to be searched for, > such as footers, and therefore my filter program can simply ignore > them. However, I don't feel safe in making the blanket assumption that > /all/ included files don't need to be searchable. > > Is it possible to add a flexible attribute system to the current > HTML::Template design? I'm thinking of something like this: > > <TMPL_INCLUDE NAME="file.txt" SEARCHABLE="no"> > > The additional attribute(s) could be ignored by HTML::Template, but hold > meaning for external programs that need additional information on the > template tag. > > I'm sure it can be done with a filter, but frankly, I think that's a > cop-out solution, being that the current filter mechanism does not have a > way to hook into HTML::Template's parser. > > > > ------------------------------------------------------- > This SF.Net email is sponsored by the new InstallShield X. > >From Windows to Linux, servers to mobile, InstallShield X is the one > installation-authoring solution that does it all. Learn more and > evaluate today! http://www.installshield.com/Dev2Dev/0504 > _______________________________________________ > Html-template-users mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/html-template-users ------------------------------------------------------- This SF.Net email is sponsored by the new InstallShield X. >From Windows to Linux, servers to mobile, InstallShield X is the one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504 _______________________________________________ Html-template-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/html-template-users