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.


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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.