Because Xslate has been inspired in TT2 Text::MicroTemplate, I’d like to introduce some features about them
TT2 is super popular template
TT2 and TMT lead Xslate, which is extremely faster than TT2 and borrows smart escaping from TMT, and Xslate has been made after PSGI, its API is suitable for PSGI, BTW, do you know PSGI or Plack? PSGI is a web application specification just like as CGI and Plack is a toolkit compatible with PSGI. To be simple, a feature which runs web applications
Do you know cpanm? This is a kind of cpan command but more fast and easy. And Xslate has a command line interface so you can easily evaluate a simple statement [DEMO]
Use of Xslate is super simple. Just three statements. Loading, creating an instance, and rendering a template.
When you want to split the template files, for example, to header files, body files, and footer files, you can use “include” directives.
Template cascading, also known as template inheritance which is implemented in Django and Smarty, is another form of “include”.
A lot of features and plugins
Easy to learn
A tiny template engine
Much faster than TT2
Written in pure Perl
Smart escaping (XSS guard)
Smart Escaping (1)
XSS: <a href=”blah”><: $foo :></a>
where $foo is <script>alert(“XSS”)</script>
What does the template engine do?
TT2: prints it as is
TMT: prints <script>alert(“XSS”)</script>
escapes HTML meta characters (<, >, &, and etc.)
decides escaping by data type (described later)
means it is safer than writing HTML by yourself
100+ times faster than TT2
Smart escaping, the same as TMT
Good for Plack/PSGI