diff --git a/compile.js b/compile.js index 1960b76..68ec1e6 100644 --- a/compile.js +++ b/compile.js @@ -80,8 +80,8 @@ function compile(string, inline) { } var replaceCode = replace.join(" +\n ") - var compiledSource = template(replaceTemplate, replaceCode) - return new Function(compiledSource) + var compiledSource = template(replaceTemplate, replaceCode); + return new Function(compiledSource); } return function template() { diff --git a/custom.js b/custom.js new file mode 100644 index 0000000..a0000ca --- /dev/null +++ b/custom.js @@ -0,0 +1,47 @@ + + +var opTag = "{"; +var clTag = "}"; +var nargs = /\{([0-9a-zA-Z]+)\}/g + + + +function isSpecialRegExpChar( c ) { + return "\^$.|?*+()[]{}".indexOf( c ) != -1; +} + + +function escapeForRegExp( str ) { + var l = str.length; + var result = ""; + for( var i=0; i" ); + result = format( "Hello {name}, I hear you come from {{city}}?", objs ); + assert.equal(result, "Hello {name}, I hear you come from {{city}}?"); + + // restoring standard open/close tags for following tests + custom.setOpenCloseTags( "{", "}" ); + + assert.end(); +}); + diff --git a/test/index.js b/test/index.js index 95b6260..b8f0230 100644 --- a/test/index.js +++ b/test/index.js @@ -1,3 +1,4 @@ require("./string-template") require("./compile-weak") require("./compile-strong") +require("./custom")