summaryrefslogtreecommitdiffstats
path: root/lib/Text/Handlebars.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Text/Handlebars.pm')
-rw-r--r--lib/Text/Handlebars.pm15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Text/Handlebars.pm b/lib/Text/Handlebars.pm
index 30a769c..fa9e32c 100644
--- a/lib/Text/Handlebars.pm
+++ b/lib/Text/Handlebars.pm
@@ -22,6 +22,10 @@ sub default_functions {
my ($length) = @_;
return [(undef) x $length];
},
+ '(is_code)' => sub {
+ my ($val) = @_;
+ return ref($val) && ref($val) eq 'CODE';
+ },
'(new_vars_for)' => sub {
my ($vars, $value, $i) = @_;
$i = 0 unless defined $i; # XXX
@@ -62,4 +66,15 @@ sub options {
return $options;
}
+sub _register_builtin_methods {
+ my $self = shift;
+ my ($funcs) = @_;
+
+ weaken(my $weakself = $self);
+ $funcs->{'(run_code)'} = sub {
+ my ($code, $vars) = @_;
+ return $self->render_string($code->(), $vars);
+ };
+}
+
1;