OK, this may be silly posting this just after I asked about it as well. However, on a hunch I tried something. It may not be what you need der_On, but I needed a custom function to do something with something and make that function available in the view. I'm posting this here in case you may find some use in it.
You can create your functions either in a controller for that view or, write it in a separate js file that you 'require' into your controller. Then you pass it to the relevant self.respond with a handle to the function. Sorry if this is not clear (I've not slept all night).
eg. I required the timezone node module. So in my geddy project dir, I just
Then, in my resource's controller, "event_items.js"
At the top of the file:
var tz = require('timezone/loaded');
Then, in the "show" part of the controller:
this.show = function (req, resp, params) {
var self = this;
geddy.model.EventItem.first(params.id, function(err, eventItem) {
self.respond({params: params, eventItem: eventItem.toObj(), tz: tz}); /* now 'tz' can be used in the show.html.ejs view */
});
};
And that's how I 'enabled' a custom helper in my view. Perhaps you can do something similar for your i18n needs? Good luck!
@devs: if this is not the canonical way of doing something like this, I would greatly appreciate some guidance. Thanks!
On Friday, December 21, 2012 8:08:42 PM UTC+8, der_On wrote: