Perl templates with inheritance
inheritance, perl, templates
Solution
I'll second the suggestion for Text::Xslate. Its syntax is even quite similar to your Jinja2 examples:
In `layouts/main.tx`:
...
<div id="page">
: block sidebar -> { }
<div id="content">
: block header-> { <h1>Default Title</h1> }
: block content -> { }
</div>
</div>
...
In another template:
: cascade layouts::main
: override header -> {
<div id="header">
...
</div>
: }
: override content -> {
<div id="content-body">
...
</div>
: }
Problem
Exists in the Perl world any template system with template inheritance? Just checked in the wikipedia Comparison_of_web_template_engines (really incomplete list) - and here isn't listed any. Inheritance = Supports the ability to inherit a layout from a parent template, separately overriding arbitrary sections of the parent template's content. Mean something like python's Jinja2: ``` #body.html <body> {% block content %} <!-- the content go here --> {% endblock %} </body> #hi.html {% extends "body.html" %} {% block content %} <h1>Hi!</h1> {% endblock %} ``` rendering `hi.html` gives ``` <body> <h1>Hi!</h1> </body> ``` Don't looking for exact Jinja2 syntax, simply looking for any template engine from the perl world what supports inheritance. (not only plain includes - like Template::Toolkit) Asking here because searching CPAN is a pain for words like "template inheritance" - shows thousands modules what not related to this question. Ps: ... and it shouldn't be something like embedded perl - should be "user editable" allowing users builds own templates without compromise a whole system - therefore can't use Mason or HTML::Mason)