From 07d17ee13777c1ea5ce00b26437ff4e778e19b22 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Mon, 15 Feb 2016 19:35:58 +0100 Subject: Move template handling code into a separate file --- js/codeq/hint.js | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'js/codeq/hint.js') 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 . */ 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 . */ 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, '>'); - });*/ - }, - prepareStaticHintContent = function (hintContent, indices, hintId) { var content = {}, langs = codeq.availableLangs, @@ -209,11 +195,11 @@ along with this program. If not, see . */ 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 . */ 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; -- cgit v1.2.1