perl – Mojolicious :: Lite with Template Toolkit

前端之家收集整理的这篇文章主要介绍了perl – Mojolicious :: Lite with Template Toolkit前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用Template Toolkit作为MojolicIoUs :: Lite中的默认渲染器.是)我有的:
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;

当我尝试点击测试服务器时,我得到:

[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.

无论我作为参数传递给’render’,都会发生这种情况.我似乎无法弄清楚如何从中获取任何有用的调试信息;但我以前没有用过Mojo.

我已经通过一些警告声明确认我的get处理程序被调用了.

解决方法

看完 Mojolicious::Plugin::TtRenderer::Enginesource之后,我想通了.该插件忽略传递给Template Toolkit的INCLUDE_PATH选项,而是从$app-> renderer_paths获取路径.所以更新我的代码包括
app->renderer->default_handler( 'tt' );
app->renderer->paths( [ './tmpl' ] );

使它工作.

原文链接:https://www.f2er.com/Perl/171358.html

猜你在找的Perl相关文章