在Text::Xslate中是将cascade
特定模板(或在其他模板引擎中包装)特定模板为主模板的好方法。也可以将include
个公共块放入模板中。
我想将include
块化成特定模板,其中cascade
成为主模板,但是以某种方式include
d模板具有可替换的部分(around
关键字)main中的某些命名部分。
简化的测试用例
use strict;
use warnings;
use FindBin qw($Bin);
use Text::Xslate;
my $tx = Text::Xslate->new(
path => [ "$Bin/template" ],
);
print $tx->render( 'some.tx' );
: cascade main
: around some -> {
some text 1
: include included;
some text 2
: }
MAIN template
: block main -> {
main DEFAULT text, should replaced with included.tx one
: } #
: block some -> {
: } #
: around main -> {
this should come from included but does not
: }
included successfully into some.tx
MAIN template
this should come from included but does not
some text 1
included successfully into some.tx
some text 2
如果我在some.tx
中使用它,则输出中的第三行不正确
: around main -> {
this should come from included but does not
: }
有效。
但是如何包含应该层叠到主模板中的块?
答案 0 :(得分:0)
: cascade main with included
: around some -> {
some text 1
: include included;
some text 2
: }