summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-10-24 18:00:21 -0500
committerJesse Luehrs <doy@tozt.net>2013-01-02 13:56:21 -0600
commit6f0daf7d3c5fa3311cb6c11257cb671981eadc3a (patch)
treefd1fe1e740a39e368ddcde2c045c2b55e20b11d0
parent32ec4a2cda7b608c8da3575318347c140a89c2f9 (diff)
downloadtext-handlebars-6f0daf7d3c5fa3311cb6c11257cb671981eadc3a.tar.gz
text-handlebars-6f0daf7d3c5fa3311cb6c11257cb671981eadc3a.zip
gfx doesn't want to support a render_string opcode
-rw-r--r--lib/Text/Handlebars.pm4
-rw-r--r--lib/Text/Handlebars/Compiler.pm12
-rw-r--r--t/mustache-spec-syntax-only.t3
3 files changed, 14 insertions, 5 deletions
diff --git a/lib/Text/Handlebars.pm b/lib/Text/Handlebars.pm
index 2bd0096..d4a3778 100644
--- a/lib/Text/Handlebars.pm
+++ b/lib/Text/Handlebars.pm
@@ -143,6 +143,10 @@ sub _register_builtin_methods {
my ($funcs) = @_;
weaken(my $weakself = $self);
+ $funcs->{'(render_string)'} = sub {
+ my ($to_render, $vars) = @_;
+ return $weakself->render_string($to_render, $vars);
+ };
$funcs->{'(make_block_helper)'} = sub {
my ($code, $raw_text, $else_raw_text, $hash) = @_;
diff --git a/lib/Text/Handlebars/Compiler.pm b/lib/Text/Handlebars/Compiler.pm
index de7b0c4..5b99471 100644
--- a/lib/Text/Handlebars/Compiler.pm
+++ b/lib/Text/Handlebars/Compiler.pm
@@ -236,7 +236,7 @@ sub is_unary {
my %unary = (
map { $_ => 1 } qw(builtin_is_array_ref builtin_is_hash_ref is_code_ref
- find_file render_string)
+ find_file)
);
return $unary{$id};
@@ -279,10 +279,12 @@ sub _generate_run_code {
);
}
- my $render_string = $self->parser->symbol('(render_string)')->clone(
- id => 'render_string',
- arity => 'unary',
- first => $to_render,
+ # XXX turn this into an opcode
+ my $render_string = $self->call(
+ $node,
+ '(render_string)',
+ $to_render,
+ $self->vars,
);
return $self->compile_ast($render_string);
diff --git a/t/mustache-spec-syntax-only.t b/t/mustache-spec-syntax-only.t
index d636e6e..90db50e 100644
--- a/t/mustache-spec-syntax-only.t
+++ b/t/mustache-spec-syntax-only.t
@@ -17,6 +17,9 @@ for my $file (dir('t', 'mustache-spec', 'specs')->children) {
&& $test->{name} =~ /standalone/i
&& $test->{name} !~ /line endings/i;
+ local $TODO = "render_string requires external functions"
+ if $file->basename eq '~lambdas.json';
+
my $opts = {
suffix => '.mustache',
path => [