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 <[EMAIL PROTECTED]> 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} = { foo => $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="[% 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/;($;=JAPH)->config(name => do {
$,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //,
";$;"]->[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;->setup;
_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/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.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/