[Dancer-users] Template engines

Oleg A. Mamontov oleg at mamontov.net
Wed Feb 16 21:16:45 CET 2011


Hello!

There is very interesting template system at CPAN - Text::Xslate
(http://search.cpan.org/~gfuji/Text-Xslate/)
The module is relative young but nice and power.

Author post his benchmark of other popular template system:
(http://search.cpan.org/~gfuji/Text-Xslate/lib/Text/Xslate.pm#High_performance)
Briefly: Text::Xslate is faster than TT over 100 times. It's impressive.

There are other interesting possibilities: smart html escaping and template
cascading (often called `template inheritance`).

For those who first heard about it i illustrate: assume a base template with 3
blocks: 'left','center' and 'right'. Now you can inherit your page from this
template and override one, two or all of this blocks together.
This method compares favorably with traditional 'wrapping' method (where you
generate `content` and wrap it with `layout`).
Template inheritance present in many template system in Python world:
Cheetah, Django, Mako and others. Now it is in Perl!

That's all lyrics, now the bad news :)

There is Dancer wrapper at CPAN: http://search.cpan.org/~franckc/Dancer-Template-Xslate/
But after several unsuccessful attempts to use it i realized one simple thing:
Dancer idea of template engine is not compatible with Text::Xslate fundamentally.
Dancer try to resolve absolute template file name, render with template system and
wrap result with `layout`. I understand that this way Dancer provides same
functionality between different template engines. It also allow `auto_page` feature.
It is valuable but we lose amazing features and working speed of Text::Xslate :(
This template system is designed for self-searching template file in list of
search directories.

Unfortunately I have no good ideas on how to combine Dancer with Text::Xslate
but I feel that this should be done :)
I am familiar with the dancer recently and may not take into account any nuances.
Any ideas and advice are welcome!

Thank you.

-- 
Cheers,
Oleg A. Mamontov

mailto:  oleg at mamontov.net

jabber:  lonerr at charla.mamontov.net
icq uin: 79-521-617
cell:    +7-903-798-1352



More information about the Dancer-users mailing list