Hello again,
Thanks for the continuing help.
I have a template in the DATA section of a Perl program
and noticed that the line numbers were from the __END__
token. I'd like a way to tell the TT parser that it
should start counting from a different value like
Perl/C's #line. Copying the #line feature may not be the
best solution since in my use case, I'd probably need to
pass the initial value in from Perl, maybe like:
$tt = Template->new(INITIAL_LINE = $initial_line);
BEGIN { $initial_line = __LINE__ + 1; }
__END__
[% ... %]
The solution should also work for different #line starts
for multiple blocks/templates (not as a parameter to new
shown above). I think Randall used different TAGS
in a 2-stage templated build system, the first stage
may want to set #line marks to convert errors back to the
original source location. There's bound to be other uses.
It's a bit tricky because line numbers are a parse time thing, right?
That's why my attempt a RAWPERL solution wasn't going to work.
It seems that #line is already used internally in TT2, see
Template::Parser::location.
Another possibility for me is to catch exceptions and add
$start to the line number reported...
Enough getting carried away,
Brad
--
There are times when a person gets carried away and talks on without
thinking too much. But this can be seen by observers when one's mind is
flippant and lacking truth. -- Hagakure http://bereft.net/hagakure/
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates