Mojolicious :: Lite with Toolkit Template

I am trying to get the Template Toolkit to work as the default renderer in Mojolicious :: Lite. What I have:

use strict; use warnings; use Mojolicious::Lite; use Mojolicious::Plugin::TtRenderer; plugin tt_renderer => { template_options => { INCLUDE_PATH => './tmpl', DEBUG => 1 } }; get '/' => sub { my $self = shift; $self->render( 'index' ); }; app->renderer->default_handler( 'tt' ); app->start; 

When I try to get to the test server, I get:

 [Fri Oct 12 14:02:02 2012] [info] Listening at "http://*:3000". Server available at http://127.0.0.1:3000. [Fri Oct 12 14:02:08 2012] [debug] Your secret passphrase needs to be changed!!! [Fri Oct 12 14:02:08 2012] [debug] GET / (Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:16.0) Gecko/20100101 Firefox/16.0). [Fri Oct 12 14:02:08 2012] [debug] Routing to a callback. [Fri Oct 12 14:02:08 2012] [debug] Nothing has been rendered, expecting delayed response. 

This happens regardless of what I pass as parameters for the "rendering". I cannot figure out how to extract useful debugging information from this; but I have not used Mojo before.

I confirmed by sending warn statements in some statements that my get handler is being called.

+6
source share
1 answer

Looking at the source Mojolicious :: Plugin :: TtRenderer :: Engine , I realized this. The plugin ignores the INCLUDE_PATH parameter passed to the Template Toolkit, and instead gets the path from $app->renderer_paths . Therefore, we update our code to include:

 app->renderer->default_handler( 'tt' ); app->renderer->paths( [ './tmpl' ] ); 

makes you work.

+8
source

Source: https://habr.com/ru/post/927594/


All Articles