diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-09-28 17:32:46 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-09-28 17:32:46 -0500 |
commit | c964148db9790676e892265327f567939619c349 (patch) | |
tree | 8823cc12b17e18d1c17cd2f472a6933f0c89e607 /t/blocks.t | |
parent | 5d1c22c9436077c5e3dede4abe55dbc8713a1e4c (diff) | |
download | text-handlebars-c964148db9790676e892265327f567939619c349.tar.gz text-handlebars-c964148db9790676e892265327f567939619c349.zip |
get blocks working
Diffstat (limited to 't/blocks.t')
-rw-r--r-- | t/blocks.t | 57 |
1 files changed, 57 insertions, 0 deletions
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; |