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_performanc...) 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@mamontov.net jabber: lonerr@charla.mamontov.net icq uin: 79-521-617 cell: +7-903-798-1352
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.
Not true. See below.
Unfortunately I have no good ideas on how to combine Dancer with Text::Xslate but I feel that this should be done :)
I use Dancer with Xslate templates for my blog: https://github.com/mfontani/Brocco config.yml change needed (a hack really): engines: xslate: cache_dir: "/tmp/wherever" cache: 1 path: - / - ./views The "path" is the important bit: - needs / so that the files that are given by full path can work - needs views/ since the main layout path is given relative to that Hope you can now enjoy Xslate and Dancer both :) -marco- -- Marco Fontani Glasgow Perl Mongers - http://glasgow.pm.org/ Join the RackSpace Cloud at: http://www.rackspacecloud.com/277.html
On Wed, Feb 16, 2011 at 9:22 PM, Marco Fontani <mfontani@cpan.org> wrote:
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.
Not true. See below.
Unfortunately I have no good ideas on how to combine Dancer with Text::Xslate but I feel that this should be done :)
I'm aware of this issue. Gugod also provided a fix for this, but I'm not sure if this is the right solution. But since this seems to be a major issue for you, I'll try to find an appropriate solution quickly.
I use Dancer with Xslate templates for my blog: https://github.com/mfontani/Brocco
config.yml change needed (a hack really):
engines: xslate: cache_dir: "/tmp/wherever" cache: 1 path: - / - ./views
The "path" is the important bit: - needs / so that the files that are given by full path can work - needs views/ since the main layout path is given relative to that
Hope you can now enjoy Xslate and Dancer both :)
yup, this works too. That's what I do with jitterbug ( https://github.com/franckcuny/jitterbug).
-marco-
-- Marco Fontani Glasgow Perl Mongers - http://glasgow.pm.org/ Join the RackSpace Cloud at: http://www.rackspacecloud.com/277.html _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
-- franck cuny http://lumberjaph.net - http://github.com/franckcuny
On Feb 16, 2011, at 11:22 PM, Marco Fontani wrote:
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.
Not true. See below.
Unfortunately I have no good ideas on how to combine Dancer with Text::Xslate but I feel that this should be done :)
I use Dancer with Xslate templates for my blog: https://github.com/mfontani/Brocco
config.yml change needed (a hack really):
engines: xslate: cache_dir: "/tmp/wherever" cache: 1 path: - / - ./views
The "path" is the important bit: - needs / so that the files that are given by full path can work - needs views/ since the main layout path is given relative to that
Hope you can now enjoy Xslate and Dancer both :)
Include '/' in search path?? This kind of `solution` i tried the first thing. I'm sure it will not recommend to anyone. PS: Now turn on 'auto_page' and 'GET /etc/passwd HTTP/1.0\r\n\r\n' ;)
-marco-
-- Marco Fontani Glasgow Perl Mongers - http://glasgow.pm.org/ Join the RackSpace Cloud at: http://www.rackspacecloud.com/277.html
-- Cheers, Oleg A. Mamontov mailto: oleg@mamontov.net jabber: lonerr@charla.mamontov.net icq uin: 79-521-617 cell: +7-903-798-1352
On Feb 16, 2011, at 11:51 PM, Oleg A. Mamontov wrote:
On Feb 16, 2011, at 11:22 PM, Marco Fontani wrote:
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.
Not true. See below.
Unfortunately I have no good ideas on how to combine Dancer with Text::Xslate but I feel that this should be done :)
I use Dancer with Xslate templates for my blog: https://github.com/mfontani/Brocco
config.yml change needed (a hack really):
engines: xslate: cache_dir: "/tmp/wherever" cache: 1 path: - / - ./views
The "path" is the important bit: - needs / so that the files that are given by full path can work - needs views/ since the main layout path is given relative to that
Hope you can now enjoy Xslate and Dancer both :)
Include '/' in search path?? This kind of `solution` i tried the first thing. I'm sure it will not recommend to anyone.
PS: Now turn on 'auto_page' and 'GET /etc/passwd HTTP/1.0\r\n\r\n' ;)
Sorry, i hurried with wrong 'auto_page' example. Anyway, i think, that '/' in search path is too risky.
-marco-
-- Marco Fontani Glasgow Perl Mongers - http://glasgow.pm.org/ Join the RackSpace Cloud at: http://www.rackspacecloud.com/277.html
-- Cheers, Oleg A. Mamontov
mailto: oleg@mamontov.net
jabber: lonerr@charla.mamontov.net icq uin: 79-521-617 cell: +7-903-798-1352
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
-- Cheers, Oleg A. Mamontov mailto: oleg@mamontov.net jabber: lonerr@charla.mamontov.net icq uin: 79-521-617 cell: +7-903-798-1352
participants (3)
-
franck -
Marco Fontani -
Oleg A. Mamontov