In Text :: Xslate - отличный способ cascade
(или обертка, в каком-либо другом шаблонизаторе) определенного шаблона в основной шаблон.Также есть возможность include
общих блоков в шаблон.
Я бы хотел include
фрагментов в конкретный шаблон, который cascade
s в основной шаблон, но таким образом, что шаблон include
d имеет части, которые заменяют (ключевое слово around
) некоторые именованные-части в основном.
Упрощенный контрольный пример
main.pl
use strict;
use warnings;
use FindBin qw($Bin);
use Text::Xslate;
my $tx = Text::Xslate->new(
path => [ "$Bin/template" ],
);
print $tx->render( 'some.tx' );
template / some.tx
: cascade main
: around some -> {
some text 1
: include included;
some text 2
: }
template / main.tx
MAIN template
: block main -> {
main DEFAULT text, should replaced with included.tx one
: } #
: block some -> {
: } #
template / includes.tx
: 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
: }
это работает.
Но как включить чанки, которые должны каскадироваться в основной шаблон?