Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

line number in debug mode when using OUTLINE mode #295

Closed
shinyapple opened this issue Jun 25, 2022 · 2 comments
Closed

line number in debug mode when using OUTLINE mode #295

shinyapple opened this issue Jun 25, 2022 · 2 comments

Comments

@shinyapple
Copy link

Hi, I've been using Template-Toolkit for many years.
I'm having trouble debugging when using OUTLINE mode.
I can't get the correct line number in debug mode.

example.pl

#!/usr/bin/env perl
use strict;
use warnings;
use Template;
use Template::Parser;
use Template::Directive;

$Template::Parser::DEBUG = 1;
$Template::Directive::PRETTY = 1;

my $tt = Template->new( { STRICT => 1, OUTLINE_TAG=>'%%' });

my $var = { title=>"TITLE" };
$tt->process(\*DATA, $var) or die $tt->error(), "\n";

__DATA__
%%
%%
%%
%%
%% title

result

[Template::Parser] compiled main template document block:
sub {
    my $context = shift || die "template sub called without context\n";
    my $stash   = $context->stash;
    my $output  = '';
    my $_tt_error;

    eval { BLOCK: {
#line 1 "input file handle"
        $output .=  $stash->get('title');
    } };
    if ($@) {
        $_tt_error = $context->catch($@, \$output);
        die $_tt_error unless $_tt_error->type eq 'return';
    }

    return $output;
}
TITLE

I'm expecting line 5, but it's not.
Does anyone know how to solve it?

@abw
Copy link
Owner

abw commented Jul 26, 2022

Thanks for the bug report. This has now been fixed and tested in https://github.com/abw/Template2/blob/master/t/outline_line.t

@abw abw closed this as completed Jul 26, 2022
@shinyapple
Copy link
Author

Sorry for the late reply.
Thank you very much in person.
It was very helpful. I will continue to use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants