diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-02-15 19:35:58 +0100 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-02-15 19:35:58 +0100 |
commit | 07d17ee13777c1ea5ce00b26437ff4e778e19b22 (patch) | |
tree | cb71a39fc6dcad48fc308601f7ccbae579403ca8 /js/codeq/hint.js | |
parent | ae2f16b29559d46abc398e1f6a0b290e75af862d (diff) |
Move template handling code into a separate file
Diffstat (limited to 'js/codeq/hint.js')
-rw-r--r-- | js/codeq/hint.js | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/js/codeq/hint.js b/js/codeq/hint.js index 05b9d2a..5b2f66e 100644 --- a/js/codeq/hint.js +++ b/js/codeq/hint.js @@ -38,7 +38,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ hintCommonTr = commonDef.hint, planDef = problemDef.plan, templatePath = [problemDef.language, problemDef.group, problemDef.problem], - templateName = templatePath.join('/'), guiDict = codeq.tr.getDictionary('gui'), btnMoreTranslations = guiDict['btn_more'] || {}, // get the default translations for the "more..." button @@ -65,19 +64,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ return result; }, - processTemplate = function (template, args) { - var fn = codeq.templator(template, templatePath, templateName); - return fn(args); -/* if (!args) - return template; - return template.replace(/\[%=(\w+)%\]/g, function(match, name) { - return args[name].toString() - .replace(/&/g, '&') - .replace(/</g, '<') - .replace(/>/g, '>'); - });*/ - }, - prepareStaticHintContent = function (hintContent, indices, hintId) { var content = {}, langs = codeq.availableLangs, @@ -209,11 +195,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ try { msg = content[lang][hintIndex]; if (typeof msg === 'string') { - trContent[lang] = processTemplate(msg, args); + trContent[lang] = codeq.template.process(msg, templatePath, args); trButton[lang] = btnMoreTranslations[lang] || 'More...'; } else { - trContent[lang] = processTemplate(msg.message, args); + trContent[lang] = codeq.template.process(msg.message, templatePath, args); trButton[lang] = msg.linkText; } } @@ -282,7 +268,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ lang = langs[i]; content = template[lang]; if (typeof content === 'string') { - translations[lang] = processTemplate(content, args); + translations[lang] = codeq.template.process(content, templatePath, args); } else { translations[lang] = 'No translation in ' + lang + ' available for ' + type + ' hint ' + serverHint.id; |