Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Jemplate CPAN distribution.

Report information
The Basics
Id: 43809
Status: resolved
Priority: 0/
Queue: Jemplate

People
Owner: Nobody in particular
Requestors: tom [...] audioboundary.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.23_1
Fixed in: (no value)



Subject: Patch for CAPTURE block implementation
Support for capturing anonymous block output: [% txt = BLOCK %] content [% END %] The attached patch provides a simple implementation for the above construct based on Template::Directive's implementation. Should handle nested directives just like the Perl version. cheers, Tom
Subject: 2009-03-03-jemplate-directive.patch
--- /usr/local/share/perl/5.8.8/Jemplate/Directive.pm 2008-03-29 21:13:43.000000000 +0000 +++ /tmp/Directive.pm 2009-03-03 13:11:31.000000000 +0000 @@ -566,7 +566,27 @@ } sub capture { - return "throw('CAPTURE not yet supported in Jemplate');"; + my ($class, $name, $block) = @_; + + if (ref $name) { + if (scalar @$name == 2 && ! $name->[1]) { + $name = $name->[0]; + } + else { + $name = '[' . join(', ', @$name) . ']'; + } + } + + return <<EOF; + +// CAPTURE +(function() { + var output = ''; + $block + stash.set($name, output); +})(); +EOF + } BEGIN {
Cool stuff, integrated your patch and wrote up a test Thanks for the submission