Subject: | Comment within inline code |
I noticed that one cannot put a comment witin a inline code block for
templates if that code block contains no carriage return.
For example, the following does not work:
$S::name = 'Bob';
my $tmpl = Text::Template->new( TYPE => 'STRING', SOURCE =>
"{\$name#comment}" );
print $tmpl->fill_in( PACKAGE => 'S' );
The following does work:
$S::name = 'Bob';
my $tmpl = Text::Template->new( TYPE => 'STRING', SOURCE =>
"{\$name#comment\n}" );
print $tmpl->fill_in( PACKAGE => 'S' );
As a workaround, I will be doing something like the following:
$S::name = 'Bob';
$text = "{\$name#comment}";
$text =~ s/\}/\n\}/g;
my $tmpl = Text::Template->new( TYPE => 'STRING', SOURCE => $text );
print $tmpl->fill_in( PACKAGE => 'S' );
It would be nice if I didn't have to manually add a \n before every }
though.