5

In Text::Xslate is great way to cascade (or wrap, in some other templating engine) specific template into main template. There is also possible to include common chunks into template.

I'd like to include chunks into specific template which cascades into main template, but in a way that included template has parts which replace (around keyword) some named-parts in main.

Simplified test case

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/included.tx

: around main -> { 
  this should come from included but does not
: }  

included successfully into some.tx

Desired output

MAIN template

  this should come from included but does not


some text 1


included successfully into some.tx


some text 2

So the third line in the output is not right, if I use it in some.tx

: around main -> { 
  this should come from included but does not
: }  

it works.

But how to include chunks, which should cascade into main-template?

Borodin
  • 126,100
  • 9
  • 70
  • 144
w.k
  • 8,218
  • 4
  • 32
  • 55

1 Answers1

0

Try cascade ... with:

template/some.tx

: cascade main with included
: around some -> {
some text 1
: include included;
some text 2
: }
Community
  • 1
  • 1
Mike
  • 21,301
  • 2
  • 42
  • 65