diff --git a/lib/util.js b/lib/util.js index 271adead..90147918 100644 --- a/lib/util.js +++ b/lib/util.js @@ -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();