feature(util) rm ownRender

This commit is contained in:
coderaiser 2014-12-12 03:44:16 -05:00
parent f0eb586e38
commit a81d2e3c42

View file

@ -363,52 +363,28 @@
return regExp;
};
/**
* function render template with view
* @templ
* @view
*/
this.render = function(templ, view) {
var ret,
NOT_ESCAPE = true,
SPACES = '\\s*',
symbols = ['{{' + SPACES, SPACES + '}}'];
ret = Util.ownRender(templ, view, symbols, NOT_ESCAPE);
return ret;
};
/**
* function render template with view and own symbols
*
* @param templ
* @param view
* @param symbols
* @param notEscape
*/
this.ownRender = function(templ, view, symbols, notEscape) {
var str, expr,
ret = templ,
firstChar,
secondChar;
firstChar = symbols[0];
secondChar = symbols[1] || firstChar;
this.render = function(templ, view) {
var str, regExp,
result = templ;
Object
.keys(view)
.forEach(function(param) {
str = view[param];
str = Util.exec(str) || str;
expr = firstChar + param + secondChar;
ret = Util.replaceStr(ret, expr, str, notEscape);
regExp = RegExp('{{\\s*' + param + '\\s*}}', 'g');
result = result.replace(regExp, str);
});
expr = firstChar + '.*' + secondChar;
ret = Util.replaceStr(ret, expr, '', notEscape);
if (result.indexOf('{{'))
result.replace(/{{\s*.*\s*}}/, '');
return ret;
return result;
};
this.type = new TypeProto();