diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-10-04 18:43:04 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-10-04 18:43:38 -0500 |
commit | 3aa97f35d6a363350e2c3c41c731c93721b348ac (patch) | |
tree | 470f9ddcf14226a06b0c31361fc49d9937fb496c /lib/Text/Handlebars.pm | |
parent | 8f48b142b49caf1d1e49b2124a27433fecbf5cfa (diff) | |
download | text-handlebars-3aa97f35d6a363350e2c3c41c731c93721b348ac.tar.gz text-handlebars-3aa97f35d6a363350e2c3c41c731c93721b348ac.zip |
make {{this}} an alias to {{.}} and make them work at the top level
Diffstat (limited to 'lib/Text/Handlebars.pm')
-rw-r--r-- | lib/Text/Handlebars.pm | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/Text/Handlebars.pm b/lib/Text/Handlebars.pm index 71b1ac1..c1afc32 100644 --- a/lib/Text/Handlebars.pm +++ b/lib/Text/Handlebars.pm @@ -130,4 +130,28 @@ sub _register_builtin_methods { }; } +sub render_string { + my $self = shift; + my ($string, $vars) = @_; + + if (ref($vars) && ref($vars) eq 'HASH') { + return $self->SUPER::render_string(@_); + } + else { + return $self->SUPER::render_string($string, { '.' => $vars }); + } +} + +sub render { + my $self = shift; + my ($name, $vars) = @_; + + if (ref($vars) && ref($vars) eq 'HASH') { + return $self->SUPER::render(@_); + } + else { + return $self->SUPER::render($name, { '.' => $vars }); + } +} + 1; |