1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
#!perl -w
use strict;
use Test::More;
use Text::Xslate;
use lib "t/lib";
use Util;
my $tx = Text::Xslate->new(path => [path], cache => 0);
my @set = (
[<<'T', { lang => 'Xslate' }, <<'X', 'with a component'],
: cascade myapp::base with myapp::cfoo
T
HEAD
FOO
Hello, Xslate world!
FOOT
X
[<<'T', { lang => 'Xslate' }, <<'X', 'with another component'],
: cascade myapp::base with myapp::cbar
T
HEAD
Hello, Xslate world!
BAR
FOOT
X
[<<'T', { lang => 'Xslate' }, <<'X', 'with components'],
: cascade myapp::base with myapp::cfoo, myapp::cbar
T
HEAD
FOO
Hello, Xslate world!
BAR
FOOT
X
[<<'T', { lang => 'Xslate' }, <<'X', 'overlay'],
: cascade with myapp::cfoo, myapp::cbar
----
: block hello -> {
This is template cascading!
: }
----
T
----
FOO
This is template cascading!
BAR
----
X
[<<'T', { lang => 'Xslate' }, <<'X', 'cascade-with as a library'],
: cascade with common
: foo()
T
This is <foo>!
X
[<<'T', { lang => 'Xslate' }, <<'X'],
: cascade with common
: macro bar -> {
This is bar!
: }
: bar()
T
before <bar>!
This is bar!
X
[<<'T', { lang => 'Xslate' }, <<'X'],
: macro bar -> {
This is bar!
: }
: bar()
: cascade with common
T
before <bar>!
This is bar!
X
[<<'T', { lang => 'Xslate' }, <<'X'],
: baz()
: cascade with common
T
This is <baz>!
X
[<<'T', { lang => 'Xslate' }, <<'X'],
: baz() | raw
: cascade with common
T
This is <baz>!
X
);
foreach my $d(@set) {
my($in, $vars, $out, $msg) = @$d;
is $tx->render_string($in, $vars), $out, $msg or diag $in;
}
done_testing;
|