Reputation: 628
Peace of mustache template:
<span class="frameSpec blackBg">{{#i18n}}Kids{{/i18n}}</span>
Peace of javascript code:
// Preparing data to view
var items = {
'items': data.matches,
'i18n' : function(){
return get_translation(key);
}
};
//--
$("#items").append(Mustache.render(items_template, items));
This doesn't work, key always is undefinded?
Upvotes: 2
Views: 2639
Reputation: 628
This is the fix for my code:
// Preparing data to view
var items = {
'items': data.matches,
'i18n' : function(){
return function(key){
return get_translation(key);
}
}
};
//--
Upvotes: 4
Reputation: 13529
Maybe you should type the function like that:
'i18n' : function(key) {
return get_translation(key);
}
I.e. the key
variable is not defined and probably is passed as a parameter of your function.
Upvotes: 0