如何在 Template Toolkit 模板文件中覆盖 WRAPPER? [英] How can I override WRAPPER in a Template Toolkit template file?
问题描述
有没有办法禁用在 WRAPPER="noreferrer">new(\%config),通过模板,还是使用 parse()
临时覆盖?我想要一个默认的 WRAPPER
(我将用于 99.9% 的模板),但排除一些.
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.
我正在通过 Catalyst::View::TT
完成这一切,就像 配置概要,除非我不希望 WRAPPER
应用于所有我的模板.
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.
推荐答案
编辑包装器,以包含如下条件:
Edit the wrapper, to include a conditional like:
[% IF no_wrapper OR template.no_wrapper %] [% content %] [% ELSE %]
top;
[% content %]
bottom;
[% END %]
这允许我在 (1) 模板内部或 (2) 从存储中禁用包装器.
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 ...;
是一个指令,它使 var
可以通过 template
哈希作为 template.var> 访问代码>
META var ...;
is a directive that makes var
accessible through the template
hash as template.var
来源:http://wiki.catalystframework.org/wiki/gettingstarted/howtos/模板包装器
这篇关于如何在 Template Toolkit 模板文件中覆盖 WRAPPER?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!