2

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?

2

2 Answers 2

4

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);
        }
     }
};
//--
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.