summaryrefslogtreecommitdiffstats
path: root/lib/Text/Xslate
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-10-05 18:30:32 -0500
committerJesse Luehrs <doy@tozt.net>2012-10-05 18:30:32 -0500
commit6ff12b877afbda62ad2cb6d748487e7674e5c396 (patch)
tree74fa460cfbb35ff23603a8ee4e3a84c7d2dda52b /lib/Text/Xslate
parentf805baad91b66f47885160afaed141a4e4c5fa67 (diff)
downloadtext-handlebars-6ff12b877afbda62ad2cb6d748487e7674e5c396.tar.gz
text-handlebars-6ff12b877afbda62ad2cb6d748487e7674e5c396.zip
change back to defining helpers and functions separately
helpers are different from functions because they implicitly receive the current context as the first argument, so they need to be declared differently. they work identically to functions in all other respects.
Diffstat (limited to 'lib/Text/Xslate')
-rw-r--r--lib/Text/Xslate/Syntax/Handlebars.pm17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Text/Xslate/Syntax/Handlebars.pm b/lib/Text/Xslate/Syntax/Handlebars.pm
index 252b4c9..a24fa00 100644
--- a/lib/Text/Xslate/Syntax/Handlebars.pm
+++ b/lib/Text/Xslate/Syntax/Handlebars.pm
@@ -5,6 +5,8 @@ use Any::Moose;
use Carp 'confess';
use Text::Xslate::Util qw($DEBUG $NUMBER neat p);
+use Text::Handlebars::Symbol;
+
extends 'Text::Xslate::Parser';
use constant _DUMP_PROTO => scalar($DEBUG =~ /\b dump=proto \b/xmsi);
@@ -29,6 +31,8 @@ sub _build_tag_end { '}}' }
sub _build_shortcut_table { +{} }
+sub symbol_class { 'Text::Handlebars::Symbol' }
+
sub split_tags {
my $self = shift;
my ($input) = @_;
@@ -584,6 +588,19 @@ sub define_function {
return;
}
+sub define_helper {
+ my $self = shift;
+ my (@names) = @_;
+
+ $self->define_function(@names);
+ for my $name (@names) {
+ my $symbol = $self->symbol($name);
+ $symbol->is_helper(1);
+ }
+
+ return;
+}
+
sub parse_literal {
my $self = shift;
my ($literal) = @_;