logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: Addendum/Correction to: Template output for email scripts adding extra : msg#00004

Subject: Re: Addendum/Correction to: Template output for email scripts adding extra line breaks
On Dec 15, 2007 10:55 AM, C Hagstrom <hagstrom@xxxxxxxx> wrote:
>This script code:
>
><code>
>my $template = HTML::Template->new(
>         filename => "$tmpl_dir/CH_line_break_test.tmpl",
>         associate => $q,
>);
>$stuff = $template->output;
>
>print MAIL $stuff;
></code>
>
>comes through as:
>
><output>
>##########################################
>
>=> this represents line 1
>
>=> this represents line 2
>
>=> this represents line 3
>
>=> this represents line 4
>
>=> this represents line 5
>
>##########################################
></output>
>
>Note: the Template file used for the above appears as:

<template>
##########################################
=> this represents line 1
=> this represents line 2
=> this represents line 3
=> this represents line 4
=> this represents line 5
##########################################
</template>
 
 
Well, I'm a bit confused.  The above doesn't look like a template file, so I'm
not sure I'm actually answering your question, but I tried a couple of things.

1.  I put the above <template></template> lines in a file named qt.tmpl,
and ran the following code:

     1  #!/usr/local/bin/perl
     2
     3  use strict;
     4  use warnings;
     5  use HTML::Template;
     6
     7  my $template = HTML::Template->new( filename => "qt.tmpl" );
     8  my $stuff = $template->output;
     9  print $stuff;

I got the following output:

##########################################
=> this represents line 1
=> this represents line 2
=> this represents line 3
=> this represents line 4
=> this represents line 5
##########################################

(Question: is that *really* your template file contents?)


2. The problem you describe reminds me of the classic beef about
extra line breaks when a template is filled in.  Of course, these
aren't really *extra*, because the template file contains them.  For
example, when I run the following code:

     1  #!/usr/local/bin/perl
     2
     3  use strict;
     4  use warnings;
     5  use HTML::Template;
     6
     7  my @array = <DATA>;
     8  my $template = HTML::Template->new( arrayref => \@array );
     9  $template->param( loop => [
    10      {line => "line1"},
    11      {line => "line2"},
    12      {line => "line3"},
    13      ] );
    14  my $stuff = $template->output;
    15  print $stuff;
    16
    17  __DATA__
    18  ##########################################
    19  <TMPL_LOOP name="loop">
    20  <TMPL_VAR name="line">
    21  </TMPL_LOOP>
    22  ##########################################

I get the following output:

##########################################

line1

line2

line3

##########################################

A template novice might complain that HTML::Template is adding extra
line breaks, but of course, they are right there in the template.  I don't
think that you're a template novice, so again I'm not sure this is answering
your question.

You say that nothing in your templates has changed.  However,
I don't think you have given a real example of one of these templates,
so beyond my guesses above, it's hard for me to know what will help.

Regards,

-- Brad

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Html-template-users mailing list
Html-template-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/html-template-users
<Prev in Thread] Current Thread [Next in Thread>