Skip Menu |

This queue is for tickets about the Template-Declare CPAN distribution.

Report information
The Basics
Id: 41327
Status: rejected
Priority: 0/
Queue: Template-Declare

People
Owner: Nobody in particular
Requestors: hanenkamp [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Useful capture subroutine
Here's a little tool I sometimes use with Template::Declare to allow me to capture a little bitty template for use a text elsewhere in some cases. See http://github.com/zostay/qublog/tree/revamp-journal-look/lib/Qublog/View.pm for some examples on how I use it. The specific use case here is that I need to assemble a list of items that are sorted by date, but reside in several tables, so I'm not sure of the sort until I do it and the text placed inside the templates once ready to render might need to be templates. I use capture {} here in a similar way to the use of defer {} in model definitions. Usage is: my $html = capture { p { 'some text } }; Definition is: sub capture(&) { my $code = shift; my $content; Template::Declare->new_buffer_frame; { $code->(); $content = Template::Declare->buffer->date || ''; } Template::Declare->end_buffer_frame; return $content; }
CC: undisclosed-recipients: ;
Subject: Re: [rt.cpan.org #41327] Useful capture subroutine
Date: Mon, 1 Dec 2008 10:31:31 -0500
To: Andrew Sterling Hanenkamp via RT <bug-Template-Declare [...] rt.cpan.org>
From: Jesse Vincent <jesse [...] fsck.com>
Show quoted text
> Usage is: > > my $html = capture { p { 'some text } }; >
But, but... my $html = p { 'some text' }; should work just as well.
Download (untitled)
application/pgp-signature 194b

Message body not shown because it is not plain text.

On Mon Dec 01 10:31:47 2008, jesse@fsck.com wrote: Show quoted text
> > Usage is: > > > > my $html = capture { p { 'some text } }; > >
> > But, but... > > my $html = p { 'some text' }; > > should work just as well.
Really? Well, dang. Template::Declare proves its awesomeness again. That should be in a synopsis somewhere... :-p