diff options
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; |