first commit

This commit is contained in:
2023-09-12 21:41:04 +02:00
commit 3361a7f053
13284 changed files with 2116755 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
/**
*
* @param usInstance Object an instance of underscore
* @param templates Object a hash containing templates as arrays of html strings
* @returns {{getTemplate: getTemplate}}
* @constructor
*/
var WpmlTemplateCompiler = function (usInstance, templates) {
var compiledTemplates = {};
return {
/**
*
* @param {string} temp
* @returns {*|false} compiled underscore template if a template for the given
* index was found, false if no such template exists
*/
getTemplate: function (temp) {
if (!templates.hasOwnProperty(temp)) {
throw 'No such template: ' + temp;
}
if (compiledTemplates[temp] === undefined) {
var template = templates[temp];
if (template instanceof Array) {
template = template.join("\n");
}
compiledTemplates[temp] = usInstance.template(template);
}
return compiledTemplates[temp];
}
};
};