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 only recommend [Text::Xslate](https://metacpan.org/module/Text::Xslate) here. It is better than TT in every way and beats out most of the competition as well. And lastly, it fits all your requirements. Literally. All of them.

It is even proven in practice, as it is used by one of the Top 100 websites worldwide and one of the Top 10 websites in Japan: [Livedoor](http://www.alexa.com/siteinfo/livedoor.com)

Xslate in comparison to TT:

* faster startup
* faster processing
* strict mode by default
* much more advanced strict mode that catches inconsistencies beyond just "var is undef"
* detailed errors that show the exact template position
* automatic HTML entity escaping (XSS-safe)
* [actively maintained](https://github.com/xslate/p5-Text-Xslate/issues) and not just [left to languish](https://rt.cpan.org/Public/Dist/Display.html?Name=Template-Toolkit)
* syntax is straight-forward and modern perl

---

Two things to note for your special case:

1. As you're porting from TT, you might want to pass `syntax => 'TTerse'` to the constructor to get a syntax that's designed to be as close to TT as possible.
2. When generating non-HTML, you want to pass `type => 'text'` to the constructor to disable `html_escape` interpolation.
take a look on [Template::Semantic](http://search.cpan.org/~tomita/Template-Semantic/) for pure template abstraction