From 9778ab1da578331c8df5d6f7fde86bf0637d5a6e Mon Sep 17 00:00:00 2001 From: Sebastian Tschan Date: Wed, 29 Feb 2012 15:34:49 +0900 Subject: [PATCH 001/106] Set viewport to device width. --- index.html | 1 + test/index.html | 1 + 2 files changed, 2 insertions(+) diff --git a/index.html b/index.html index 622fbed..147a688 100644 --- a/index.html +++ b/index.html @@ -16,6 +16,7 @@ JavaScript Templates Demo + diff --git a/test/index.html b/test/index.html index e07422f..212dd0f 100644 --- a/test/index.html +++ b/test/index.html @@ -15,6 +15,7 @@ JavaScript Templates Test + From 9b0f41f17921f63360c6ddce30692af817e11063 Mon Sep 17 00:00:00 2001 From: Sebastian Tschan Date: Tue, 17 Jul 2012 12:23:46 +0200 Subject: [PATCH 002/106] Added X-UA-Compatible meta tag to force latest IE rendering engine or ChromeFrame if installed. --- index.html | 1 + test/index.html | 1 + 2 files changed, 2 insertions(+) diff --git a/index.html b/index.html index 147a688..40bfa06 100644 --- a/index.html +++ b/index.html @@ -13,6 +13,7 @@ --> + JavaScript Templates Demo diff --git a/test/index.html b/test/index.html index 212dd0f..39a47d7 100644 --- a/test/index.html +++ b/test/index.html @@ -13,6 +13,7 @@ --> + JavaScript Templates Test From 96c33a5410010f4899a32db04b2ace6d064a0f2f Mon Sep 17 00:00:00 2001 From: Sebastian Tschan Date: Wed, 14 Nov 2012 14:57:51 +0100 Subject: [PATCH 003/106] Minor README update. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5f9d6e9..5f5b9bf 100644 --- a/README.md +++ b/README.md @@ -222,7 +222,7 @@ var result = tmpl("

{%=p.title%}

", {title: "JavaScript Templates"}); ### Template parsing The template contents are matched and replaced using the regular expression **tmpl.regexp** and the replacement function **tmpl.func**. The replacement function operates based on the [parenthesized submatch strings](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_function_as_a_parameter). -To use different tags for the template syntax, override **tmpl.regexp** with a modified regular expression, by exchanging all occurrences of "**\\{%**" and "**%\\}**", e.g. with "**\\[%**" and "**%\\]**": +To use different tags for the template syntax, override **tmpl.regexp** with a modified regular expression, by exchanging all occurrences of "{%" and "%}", e.g. with "[%" and "%]": ```js tmpl.regexp = /([\s'\\])(?![^%]*%\])|(?:\[%(=|#)([\s\S]+?)%\])|(\[%)|(%\])/g; @@ -300,7 +300,7 @@ Use **include(str, obj)** to include content from a different template: ``` -If else condition: +**If else condition**: ```html {% if (o.author.url) { %} @@ -310,7 +310,7 @@ If else condition: {% } %} ``` -For loop: +**For loop**: ```html
    From 6ad43cf40b1f7b0425bf9be41c1acdb64fd749a3 Mon Sep 17 00:00:00 2001 From: Sebastian Tschan Date: Mon, 17 Jun 2013 14:46:31 -0500 Subject: [PATCH 004/106] Print out falsy values. Closes #26. --- Makefile | 2 +- README.md | 10 +--------- index.html | 23 +++++++++++++---------- package.json | 8 ++++---- runtime.js | 4 ++-- test/index.html | 8 ++++---- test/template.html | 1 - test/test.js | 21 ++++++++++++--------- tmpl.js | 6 +++--- tmpl.min.js | 2 +- 10 files changed, 41 insertions(+), 44 deletions(-) delete mode 100644 test/template.html diff --git a/Makefile b/Makefile index 659aa99..4177b32 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ .PHONY: js js: - uglifyjs -nc tmpl.js > tmpl.min.js + node_modules/.bin/uglifyjs tmpl.js -c -m -o tmpl.min.js diff --git a/README.md b/README.md index 5f5b9bf..790060c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # JavaScript Templates ## Demo -[JavaScript Templates Demo](http://blueimp.github.com/JavaScript-Templates/) +[JavaScript Templates Demo](http://blueimp.github.io/JavaScript-Templates/) ## Usage @@ -271,14 +271,6 @@ Use dot notation to print nested properties: {%=o.author.name%} ``` -Note that the JavaScript Templates engine prints **falsy** values as empty strings. -That is, **undefined**, **null**, **false**, **0** and **NaN** will all be converted to **''**. -To be able to print e.g. the number 0, convert it to a String before using it as an output variable: - -```html -

    {%=0+''%}

    -``` - ### Evaluation Use **print(str)** to add escaped content to the output: diff --git a/index.html b/index.html index 40bfa06..528362d 100644 --- a/index.html +++ b/index.html @@ -1,7 +1,7 @@ - + JavaScript Templates Demo - - + + - - - + +