Hi!

> 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.

I use this filter:

our $line_merger = sub {
        my $text_ref = shift;
        # Removes HTML comment style format from the tags (so that next regex 
works)
        $$text_ref =~ s/<!--\s*(~?\/?TMPL_.+?)\s*-->/<$1>/gis;
        # "Cleans" tags in such a way that it removes the space characters
and ~ (so if there is no ~ it does not
        # remove anything)
        $$text_ref =~ s/(?:\n[
\t]*(?=<~))?<~?(\/?TMPL_[^>~]+)~?(\/?)>(?:(?:(?<=~\/>)|(?<=~>))[
\t]*\n)?/<$1$2>/gis;
};

The idea is that I can use ~ character to specify that I want newline removed.

For example:

<~TMPL_VAR NAME="foo"~>

will remove newline before and after the tag (if there is any).

In most cases I use only second ~ as this efficiently (in most
template uses) removes all newlines after the tags and so there are no
empty lines in the output.


Mitar


-------------------------------------------------------
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