Question: I have been using template toolkit for extending an existing domain specific language(verilog) for over 3 years now. While overall I am happy with it, the major irritant is that when there is a syntax/undef error the error message does not contain the correct line number information to debug the error.

e.g. I would get a message indicating "0 is not defined" since I would be using [%x.0%] and similar constructs at multiple locations in the file figuring out which line has the problem becomes difficult.

TT3 seems to be under development indefinitely

My question to the gurus is is there a better alternative to TT. My requirements are

1. Support for complex data structures
2. Good error reporting and debug capabilities.
3. Stable and proven ( no alpha/beta level engines)
4. Extensible (plugin's etc)
5. Should not be restricted to a given language (html etc.)
6. support for IF/Else, looping(foreach while), Loop indexing, etc.
7. Preferably perl
8. Support for data dumper or equivalent plugin from within the template is a plus

Answer: 
I can suggest HTML::Template:Compiled (but note I'm the author ;-)

It is quite compatible to HTML::Template, but has additional features.

> 
> Support for complex data structures
> 
> 
> 

yes

> 
> Good error reporting and debug capabilities.
> 
> 
> 

You can debug cache hits, misses, automatically add template filename to output and can use a filter "DUMP" for the current variable in stash (or any variable).
If it's easy to implement I'll happily add more useful debugging.

> 
> Stable and proven ( no alpha/beta level engines)
> 
> 
> 

I would consider it stable now, with the documented limitations/bugs (for example query())

> 
> Extensible (plugin's etc)
> 
> 
> 

supports escape (filter) plugins and more, though the latter is not documented very well yet.

> 
> Should not be restricted to a given language (html etc.)
> 
> 
> 

yes

> 
> support for IF/Else, looping(foreach while), Loop indexing, etc. 
> 
> 
> 

yes

> 
> Preferably perl
> 
> 
> 

yes

> 
> Support for data dumper or equivalent plugin from within the template is a plus
> 
> 
> 

like mentioned above, use escape=dump

all additional features are listed in the documentation:
<https://metacpan.org/release/HTML-Template-Compiled>
at "ADDITIONAL FEATURES"

edit: regarding reporting runtime errors: unfortunately H::T::C also does not report the template line number for errors that happen at runtime, since it compiles the template to perl-code (I think I experimented with manipulating line numbers once, maybe I'll have another look).
template syntax errors are reported with the correct line number.

edit2:
So here's an example with the new options warnings and line\_info:

t/templates/line\_info1.html:

```
test
test2
test3
foo:<%= foo %> undef line 4
test4

```

script:

```
use HTML::Template::Compiled;
my $t = HTML::Template::Compiled->new(
    filename => "t/templates/line_info1.html",
    warnings => 1,
    line_info => 1,
);
say $t->output;
__END__
Use of uninitialized value in concatenation (.) or string at t/templates/line_info1.html line 4.
test
test2
test3
foo: undef line 4
test4

```
take a look on [Template::Semantic](http://search.cpan.org/~tomita/Template-Semantic/) for pure template abstraction