[Catalyst] Jemplate View and Catalyst Object

Patrick McDonnell kc9ddi at gmail.com
Thu Jul 19 17:55:41 GMT 2007


Yeah, that's what I've been doing to make it work.  Just wondering if there
was some obvious better way to do it that I was missing.  Thanks for the
replies.

On 7/18/07, Jonathan Rockway <jon at jrock.us> wrote:
>
> On Wednesday 18 July 2007 02:39:22 pm Patrick McDonnell wrote:
> > TTSite view doesn't seem to exist under the Jemplate views.  For
> instance,
> > in a TTSite template, I can do something like [%
> > Catalyst.uri_for('myAction') %], but I cannot do that under the Jemplate
> > templates.
>
> Right.  [% ... %]s are expanded on the *client side* by the browser.  Of
> course they can't call methods on the Catalyst object.
>
> Here's a solution.  In a controller where your AJAXy actions live, do
> something like:
>
>   package MyApp::Controller::AJAXy::Stuff;
>   ....
>   sub begin :Private {
>      $c->stash->{action} =3D { foo =3D> $c->uri_for('/foo'), ... };
>   }
>
>    # your actions go here
>    sub foo :Local { ... }
>    ....
>
>   sub end :Private {
>      # convert stash to JSON or whatever
>   }
>
> Basically you just send some extra metadata (about actions) back with each
> response.  Then in your jemplate you can say:
>
>   <a href=3D"[% action.foo %]/some/arguments">whatever</a>
>
> Keep in mind that TT's "uri" filter is available for escaping
> some/arguments
> if necessary.
>
> Anyway, this is not ideal... but it is easy to do.
>
> For extra credit create an RPC interface and integrate it with Jemplate
> and
> Catalyst :)  The Asynapse talk at YAPC::Asia inspired me to think about
> doing
> something like that, but I haven't gotten to it yet.  Implementations
> welcome.
>
> Regards,
> Jonathan Rockway
> --
> package JAPH;use Catalyst qw/-Debug/;($;=3DJAPH)->config(name =3D> do {
> $,.=3Dreverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //,
> ";$;"]->[$_].q; ;for 1..4;$,=3D~s;^.;;;$,});$;->setup;
>
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070719/548f4=
784/attachment.htm


More information about the Catalyst mailing list