Allow the modulo operator in evaluation context. Closes #30 · htta17/JavaScript-Templates@8d3c890 · GitHub
Skip to content

Commit 8d3c890

Browse files
committed
Allow the modulo operator in evaluation context. Closes blueimp#30
1 parent ca2597e commit 8d3c890

6 files changed

Lines changed: 21 additions & 10 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "blueimp-tmpl",
3-
"version": "2.2.2",
3+
"version": "2.3.0",
44
"title": "JavaScript Templates",
55
"description": "< 1KB lightweight, fast & powerful JavaScript templating engine with zero dependencies. Compatible with server-side environments like node.js, module loaders like RequireJS and all web browsers.",
66
"keywords": [

js/tmpl.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* JavaScript Templates 2.2.0
2+
* JavaScript Templates 2.3.0
33
* https://github.com/blueimp/JavaScript-Templates
44
*
55
* Copyright 2011, Sebastian Tschan
@@ -12,7 +12,7 @@
1212
* http://ejohn.org/blog/javascript-micro-templating/
1313
*/
1414

15-
/*jslint evil: true, regexp: true */
15+
/*jslint evil: true, regexp: true, unparam: true */
1616
/*global document, define */
1717

1818
(function ($) {
@@ -34,15 +34,15 @@
3434
tmpl.load = function (id) {
3535
return document.getElementById(id).innerHTML;
3636
};
37-
tmpl.regexp = /([\s'\\])(?![^%]*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g;
37+
tmpl.regexp = /([\s'\\])(?!(?:[^{]|\{(?!%))*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g;
3838
tmpl.func = function (s, p1, p2, p3, p4, p5) {
39-
if (p1) { // whitespace, quote and backspace in interpolation context
39+
if (p1) { // whitespace, quote and backspace in HTML context
4040
return {
4141
"\n": "\\n",
4242
"\r": "\\r",
4343
"\t": "\\t",
4444
" " : " "
45-
}[s] || "\\" + s;
45+
}[p1] || "\\" + p1;
4646
}
4747
if (p2) { // interpolation: {%=prop%}, or unescaped: {%#prop%}
4848
if (p2 === "=") {

js/tmpl.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "blueimp-tmpl",
3-
"version": "2.2.2",
3+
"version": "2.3.0",
44
"title": "JavaScript Templates",
55
"description": "< 1KB lightweight, fast & powerful JavaScript templating engine with zero dependencies. Compatible with server-side environments like node.js, module loaders like RequireJS and all web browsers.",
66
"keywords": [

test/test.js

Lines changed: 12 additions & 1 deletion

0 commit comments

Comments
 (0)