yup, I'm using reusable TT2 widgets via [% PROCESS widget.tt2 %] to render
given objects (e.g. row of a given table) so I can call them from several
other TT2 pages (and on their own in AJAX calls).
root/src/foo/list.tt2
[% FOREACH foo = list_of_foos %]
[% PROCESS foo/brief_summary.tt2
entry = foo
%]
[% END %]
root/src/foo/brief_summary.tt2
<h1>[% entry.title %]</h1>
<p>[% entry.content %]</p>
If you want to display the same widgets on the page for "bar" (which also
have "foos")
root/src/bar/list.tt2
[% FOREACH foo = bar.get_foos %]
[% PROCESS foo/brief_summary.tt2
entry = foo
%]
[% END %]
FWIW I can then serve these widgets on their own in simple AJAX calls by
changing the wrapper applied in root/lib/site/wrapper (e.g. based on CGI
param "?format=AJAX"). Sending HTML snippets via AJAX is less efficient than
sending JSON and client-side rendering with javascript (Jemplate), but when
the components are small and simple, I've found this useful.
Ian
On Fri, Mar 7, 2008 at 12:43 AM, Byron Young <[EMAIL PROTECTED]>
wrote:
> You can call another template from within the template you specified in
> the stash, and pass the stash parameters along. I don't use TT, but I think
> PROCESS is how you call other templates.
>
> HTH
>
> Byron
>
> ------------------------------
> *From:* Emily Heureux [mailto:[EMAIL PROTECTED]
> *Sent:* Thursday, March 06, 2008 2:36 PM
> *To:* 'The elegant MVC web framework'
> *Subject:* [Catalyst] sending a variable to more than one tt2 template
>
> Hi, I have a variable in a Controller method sent to the stash for a
> particular tt file. What if I want that same variable to be available to
> another tt file? I assume I cannot set two templates in one method.
>
>
>
> Thanks,
>
> Emily
>
>
>
> _______________________________________________
> List: [email protected]
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/[email protected]/
> Dev site: http://dev.catalyst.perl.org/
>
>
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/