diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-10-05 17:02:06 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-10-05 17:02:06 -0500 |
commit | f805baad91b66f47885160afaed141a4e4c5fa67 (patch) | |
tree | 27bed1432b7b24fef2530aceefc43ada6166fcb0 /lib/Text | |
parent | 7ed1c283ee25388f117f820d40317d749bd40b54 (diff) | |
download | text-handlebars-f805baad91b66f47885160afaed141a4e4c5fa67.tar.gz text-handlebars-f805baad91b66f47885160afaed141a4e4c5fa67.zip |
why was i defining things there?
Diffstat (limited to 'lib/Text')
-rw-r--r-- | lib/Text/Handlebars.pm | 43 |
1 files changed, 20 insertions, 23 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; } |