Hello,

I would first like to say I'm a long time user, first time poster...

I have always used HTML::Template to generate web pages in the past but have
recently started work on a project that creates a config file and I decided
to use HTML::Template to help separated the hard coded config info from my
code.  This has worked out great in all but one regard.

All the non TMPL_VAR tags end up leaving blank lines behind because I leave
them on their own lines for the sake of being able to read the tmpl file
easily.  This how ever makes it hard to read the generated config file
because of all the extra white space.

I have always felt this was an issue but did not care enough to post about
it because the results were "just" HTML source and the like.  I can deal
with reading spaced out HTML source but this config is going to be read by
others that will need to be able to read and understand it quickly.

While looking over the documentation I found the ability to filter the tmpl
before it is written out and created the following code for the following
contrived sample:

my $filter = sub {
    my $text_ref = shift;
    $$text_ref =~ s/\n\| *//g;
};

my $tmpl = HTML::Template->new( filename => $template, filter => $filter );

|<tmpl_if name="stuff">
|  <tmpl_loop name="stuff">
This <tmpl_var name="key"> has that <tmpl_var name="value">
|  </tmpl_loop>
|<tmpl_else>
# Nothing to see here
|</tmpl_if>

This gets me the results I was looking for but feel that it is very much a
kludge.  Have I missed something in the docs like a param for the
constructor that automagicly does the same thing I have done minus me having
to do anything?  Having seen the results of an HTML::Template minus the
blank lines makes me want to see such results all the time without modifying
my code and templates to do so.

Thanks,

--
David Steinbrunner




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Html-template-users mailing list
Html-template-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to