diff --git a/mustache.js b/mustache.js index 857193d..5810822 100644 --- a/mustache.js +++ b/mustache.js @@ -131,14 +131,24 @@ var Mustache = function() { // for each {{_i}}{{/i}} section do... return html.replace(regex, function(match, content) { - var translation_mode; - if (that.pragmas && that.pragmas["TRANSLATION-HINT"] && that.pragmas["TRANSLATION-HINT"]['mode']) { - translation_mode = { _mode: that.pragmas["TRANSLATION-HINT"]['mode'] }; - } else if (context['_mode']) { - translation_mode = { _mode: context['_mode'] }; + var translationMode; + + if (that.pragmas && that.pragmas["TRANSLATION-HINT"] && that.pragmas["TRANSLATION-HINT"].mode) { + translationMode = that.pragmas["TRANSLATION-HINT"].mode; + } else if (context['_TRANSLATION-HINT_mode']) { + translationMode = context['_TRANSLATION-HINT_mode']; + } + + var params = content; + + if (translationMode) { + params = { + text: content, + mode: translationMode + }; } - return _(content, translation_mode); + return _(params); }); },