From f805baad91b66f47885160afaed141a4e4c5fa67 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 5 Oct 2012 17:02:06 -0500 Subject: why was i defining things there? --- lib/Text/Handlebars.pm | 43 ++++++++++++++++++++----------------------- t/helpers-examples.t | 2 -- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/lib/Text/Handlebars.pm b/lib/Text/Handlebars.pm index cb5c6b5..25075b1 100644 --- a/lib/Text/Handlebars.pm +++ b/lib/Text/Handlebars.pm @@ -11,6 +11,26 @@ sub default_functions { my $class = shift; return { %{ $class->SUPER::default_functions(@_) }, + with => sub { + my ($context, $new_context, $options) = @_; + return $options->{fn}->($new_context); + }, + each => sub { + my ($context, $list, $options) = @_; + return join '', map { $options->{fn}->($_) } @$list; + }, + if => sub { + my ($context, $conditional, $options) = @_; + return $conditional + ? $options->{fn}->($context) + : $options->{inverse}->($context); + }, + unless => sub { + my ($context, $conditional, $options) = @_; + return $conditional + ? $options->{inverse}->($context) + : $options->{fn}->($context); + }, '(is_array)' => sub { my ($val) = @_; return ref($val) && ref($val) eq 'ARRAY'; @@ -70,29 +90,6 @@ sub options { my $options = $class->SUPER::options(@_); $options->{compiler} = 'Text::Handlebars::Compiler'; - $options->{function} = { - ($options->{function} ? %{ $options->{function} } : ()), - with => sub { - my ($context, $new_context, $options) = @_; - return $options->{fn}->($new_context); - }, - each => sub { - my ($context, $list, $options) = @_; - return join '', map { $options->{fn}->($_) } @$list; - }, - if => sub { - my ($context, $conditional, $options) = @_; - return $conditional - ? $options->{fn}->($context) - : $options->{inverse}->($context); - }, - unless => sub { - my ($context, $conditional, $options) = @_; - return $conditional - ? $options->{inverse}->($context) - : $options->{fn}->($context); - }, - }, return $options; } diff --git a/t/helpers-examples.t b/t/helpers-examples.t index 73c053a..1df8e99 100644 --- a/t/helpers-examples.t +++ b/t/helpers-examples.t @@ -7,7 +7,6 @@ use Test::Handlebars; use Text::Xslate 'mark_raw'; -{ local $TODO = "unimplemented"; render_ok( { function => { @@ -92,6 +91,5 @@ TEMPLATE RENDERED "example" ); -} done_testing; -- cgit v1.2.3-54-g00ecf