Some more refactoring of template function.
parent
8b0b320103
commit
f2a3c7aebd
|
@ -511,10 +511,10 @@ function makeUrl(url, context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function template(tmpl, context, filter) {
|
function template(tmpl, context, filter) {
|
||||||
for (var key in context) if (context.hasOwnProperty(key)) {
|
return tmpl.replace(/\{([^\}]+)\}/g, function(m, key) {
|
||||||
tmpl = tmpl.replace(new RegExp('{' + key + '}', 'g'), filter ? filter(context[key]) : context[key]);
|
// If key don't exists in the context we should keep template tag as is
|
||||||
}
|
return key in context ? (filter ? filter(context[key]) : context[key]) : m;
|
||||||
return tmpl;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getElementClassNames(elem, mod) {
|
function getElementClassNames(elem, mod) {
|
||||||
|
|
Loading…
Reference in New Issue