From 077b7b5eaf049170e8b875801ea23fabeb889218 Mon Sep 17 00:00:00 2001 From: Ben Cherry Date: Mon, 6 Dec 2010 17:48:42 -0800 Subject: [PATCH] send translation mode in single parameter to _ --- mustache.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) 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); }); },