summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-09-28 17:32:46 -0500
committerJesse Luehrs <doy@tozt.net>2012-09-28 17:32:46 -0500
commitc964148db9790676e892265327f567939619c349 (patch)
tree8823cc12b17e18d1c17cd2f472a6933f0c89e607 /t
parent5d1c22c9436077c5e3dede4abe55dbc8713a1e4c (diff)
downloadtext-handlebars-c964148db9790676e892265327f567939619c349.tar.gz
text-handlebars-c964148db9790676e892265327f567939619c349.zip
get blocks working
Diffstat (limited to 't')
-rw-r--r--t/001-basic.t6
-rw-r--r--t/002-expressions.t6
-rw-r--r--t/003-safestring.t5
-rw-r--r--t/blocks.t57
4 files changed, 69 insertions, 5 deletions
diff --git a/t/001-basic.t b/t/001-basic.t
index 3873076..28d54c1 100644
--- a/t/001-basic.t
+++ b/t/001-basic.t
@@ -1,9 +1,11 @@
+#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
-use Text::Xslate;
-my $tx = Text::Xslate->new(syntax => 'Handlebars');
+use Text::Handlebars;
+
+my $tx = Text::Handlebars->new;
is(
$tx->render_string(
diff --git a/t/002-expressions.t b/t/002-expressions.t
index afe66d8..730196f 100644
--- a/t/002-expressions.t
+++ b/t/002-expressions.t
@@ -1,9 +1,11 @@
+#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
-use Text::Xslate;
-my $tx = Text::Xslate->new(syntax => 'Handlebars');
+use Text::Handlebars;
+
+my $tx = Text::Handlebars->new;
is(
$tx->render_string(
diff --git a/t/003-safestring.t b/t/003-safestring.t
index 8e095ea..27d9ac1 100644
--- a/t/003-safestring.t
+++ b/t/003-safestring.t
@@ -1,9 +1,12 @@
+#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
+
+use Text::Handlebars;
use Text::Xslate 'mark_raw';
-my $tx = Text::Xslate->new(syntax => 'Handlebars');
+my $tx = Text::Handlebars->new;
is(
$tx->render_string(
diff --git a/t/blocks.t b/t/blocks.t
new file mode 100644
index 0000000..bbc22b9
--- /dev/null
+++ b/t/blocks.t
@@ -0,0 +1,57 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+use Text::Handlebars;
+
+my $tx = Text::Handlebars->new;
+
+is(
+ $tx->render_string(
+ 'This is {{#shown}}shown{{/shown}}',
+ { shown => 1 },
+ ),
+ 'This is shown',
+);
+
+is(
+ $tx->render_string(
+ 'This is {{#shown}}shown{{/shown}}',
+ { shown => 0 },
+ ),
+ 'This is ',
+);
+
+is(
+ $tx->render_string(
+ 'This is {{#shown}}shown{{/shown}}',
+ { shown => [({}) x 3] },
+ ),
+ 'This is shownshownshown',
+);
+
+is(
+ $tx->render_string(
+ 'This is {{#shown}}{{content}}{{/shown}}',
+ { shown => { content => 'SHOWN' } },
+ ),
+ 'This is SHOWN',
+);
+
+is(
+ $tx->render_string(
+ 'This is {{#shown}}{{content}}{{/shown}}',
+ {
+ shown => [
+ { content => '3' },
+ { content => '2' },
+ { content => '1' },
+ { content => 'Shown' },
+ ],
+ },
+ ),
+ 'This is 321Shown',
+);
+
+done_testing;