Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

What is the best way to get Catalyst::Plugin::I18N objects into a Jemplate?

by uG (Scribe)
on May 11, 2011 at 04:02 UTC ( #904071=perlquestion: print w/ replies, xml ) Need Help??
uG has asked for the wisdom of the Perl Monks concerning the following question:

By using Jemplate, I have been able to create an ajax-y Catalyst application that works even when javascript is disabled. To accomplish this with a single set of templates (I love it) requires passing everything in as lists or arrays (instead of calling methods like c.uri_for, or accessing model objects directly). Why? Because I wanted my ajax to talk with a REST API, and Catalyst::Controller::REST's status helpers expect (you guessed it) lists or arrays as mentioned earlier.

At first I thought, "Wow, this is really getting me to keep my V away from my M and C." But then I was going through the Catalyst advent calender and decided to try the I18N tutorial. Everything works great if javascript is disabled, because I invoked it by calling the c.loc in the template. Naturally this will not work if the template is called by Jemplate.

The only solution that comes to my mind is just passing in the various c.loc variables from the controller. But this seems unnecessarily ugly when you consider having to send in stuff like 'Hello', 'User', etc. An example would be updating a user panel to replace a login button with "Hello username!"

Well, that or using a js I18N plugin. but i'd like it to be handled server side. Somebody humble me with an overly simple (and obvious in hindsight) solution.

Comment on What is the best way to get Catalyst::Plugin::I18N objects into a Jemplate?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://904071]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2014-12-22 22:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (133 votes), past polls