From c964148db9790676e892265327f567939619c349 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 28 Sep 2012 17:32:46 -0500 Subject: get blocks working --- t/001-basic.t | 6 ++++-- t/002-expressions.t | 6 ++++-- t/003-safestring.t | 5 ++++- t/blocks.t | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 t/blocks.t (limited to 't') 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; -- cgit v1.2.3-54-g00ecf