I am using IronRouter in my project which has content in different languages. To display message codes I have used UI.registerHelper, as follows:
UI.registerHelper('loadMessageCode', function(message) {
//Logic in here to load string inside a template
return 'sample-string-in-a-language';
});
My content is loaded from a json file, with strings being specified in different languages as follows. This gets added into a Mongo.Collection when the app starts.
{
"name": "Pages",
"items": [
{
"title": {
"en": "About Us",
"de": "Über"
},
"slug": {
"en": "about",
"de": "über"
},
"content": {
"en": "......"
"de": "......"
}
}
]
}
When generating the links for my content from within my template, I am using IronRouters pathFor function, which I have used before to generate the link. This worked as follows:
<a href="{{pathFor 'content' _page_slug=this.slug}}" title="{{title}}">
{{title}}
</a>
This worked fine before I refactored the structure of my Json file. Now what I want to do is something along the lines of the following:
<a href="{{pathFor 'content' _page_slug=<Use my helper function to dig out the slug>}}" title="{{title}}">
{{title}}
</a>
My question is, can this be done and if so, how?