如何覆盖 Template Toolkit 模板文件中的 WRAPPER?
有没有办法禁用 new(\%config),通过模板还是使用 parse()
进行临时覆盖?我想要一个默认的 WRAPPER
(我将用于 99.9% 的模板),但排除一些。
我通过 Catalyst::View::TT
完成这一切,就像 配置概要,但我不希望 WRAPPER
应用于我的所有模板。
Is there a way to disabling a WRAPPER
that was set in new(\%config), through either the template, or a temporary override with parse()
? I want to have a single default WRAPPER
(that I'll use for 99.9% of my templates), but exclude a few.
I'm doing this all through Catalyst::View::TT
just like the example in the configuration synopsis, except I don't want the WRAPPER
to apply to all of my templates.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
编辑包装器,以包含如下条件:
这允许我禁用包装器(1)在模板内部,或(2)从存储中。
[%- META no_wrapper = 1 -%]
$c->stash->{no_wrapper} = 1
META var ...;
> 是一个指令,使var
通过template
哈希作为template.var
源进行访问:http://wiki.catalystframework.org/wiki/gettingstarted/howtos/template_wrappers
Edit the wrapper, to include a conditional like:
This allows me to disable the wrapper either (1) inside of template, or (2) from the stash.
[%- META no_wrapper = 1 -%]
$c->stash->{no_wrapper} = 1
META var ...;
is a directive that makesvar
accessible through thetemplate
hash astemplate.var
source: http://wiki.catalystframework.org/wiki/gettingstarted/howtos/template_wrappers
在
site/wrapper
本身中定义异常,顺便说一句,那里已经定义了异常。Define exceptions in
site/wrapper
itself, and btw there are exceptions defined there already.我偶然遇到了同样的问题,并创建了一个更通用的解决方案,允许动态切换布局,或者根本没有布局。请参阅此处:
多个布局/包装器舞者和模板::工具包
I stumbled into the same problem, and created a more generalized solution that allows for dynamic switching of layouts, or to have no layout at all. See here:
More than one layout/wrapper with Dancer and Template::Toolkit