Skip Menu |

This queue is for tickets about the Template-Alloy CPAN distribution.

Report information
The Basics
Id: 79641
Status: resolved
Priority: 0/
Queue: Template-Alloy

People
Owner: Nobody in particular
Requestors: antti.linno [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Using comment in template causes error.
Date: Fri, 14 Sep 2012 10:22:40 +0300
To: bug-Template-Alloy [...] rt.cpan.org
From: Antti Linno <antti.linno [...] gmail.com>
Good day. Used minimal included example use Modern::Perl '2013'; use Template::Alloy::TT; my $t = Template::Alloy->new( INCLUDE_PATH => ['.'], ); my $swap = { key1 => 'val1', key2 => 'val2', code => sub { 42 }, hash => {a => 'b'}, }; # print to STDOUT $t->process('template.tt', $swap) || die $t->error; Template (template.tt): [% key1 %] When I changed the template to [% # Test comment. %] [% key1 %] Got error: parse error - template.tt line 1 char 19: Not sure how to continue parsing When I'm using this with template toolkit, it works without problems. (Actually stumbled upon this error following the catalyst tutorial) https://metacpan.org/module/Catalyst::Manual::Tutorial::03_MoreCatalystBasics#Create-a-TT-Template-Page Not sure, if the dot should be supported in comments, or not. Greetings, Antti
I have fixed Template::Alloy to have this behavior. It is fixed in version 1.018 for any perl version greater than 5.10. The behavior you asked for is actually buggy behavior. The problem is that Template::Toolkit doesn't use a real parser - it uses a tokenizer and it blindly looks for tags and then interprets what is between them. Template::Alloy scans progressively through the document parsing as it goes. It didn't know (and arguably shouldn't have known) that a close tag was hidden in the commented out portion since a comment is supposed to be valid until the end of the line. I had to actually make the parser of Template::Alloy a little more dumb to allow for this behavior. If not for Template::Toolkit compatibility I likely wouldn't have added the "feature." It is possible that this will break other users with previously valid commented out sections. Had you simply removed the space between the opening tag and the comment, you would've been fine. Anyway - this is now resolved in 1.018.