summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-10-05 17:02:06 -0500
committerJesse Luehrs <doy@tozt.net>2012-10-05 17:02:06 -0500
commitf805baad91b66f47885160afaed141a4e4c5fa67 (patch)
tree27bed1432b7b24fef2530aceefc43ada6166fcb0
parent7ed1c283ee25388f117f820d40317d749bd40b54 (diff)
downloadtext-handlebars-f805baad91b66f47885160afaed141a4e4c5fa67.tar.gz
text-handlebars-f805baad91b66f47885160afaed141a4e4c5fa67.zip
why was i defining things there?
-rw-r--r--lib/Text/Handlebars.pm43
-rw-r--r--t/helpers-examples.t2
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;