From 806d34efa0cc7abbbb535fdba16c3fdbc8049141 Mon Sep 17 00:00:00 2001 From: Sebastian Tschan Date: Mon, 11 Nov 2013 18:25:30 +0100 Subject: [PATCH 01/96] Added mocha grunt tasks for both server- (NodeJS) and client-side (PhantomJS) tests. --- Gruntfile.js | 71 +++++++++++++++++++++++++++++++++++++++ Makefile | 4 --- bower.json | 80 +++++++++++++++++++++++--------------------- js/runtime.js | 3 +- js/tmpl.js | 3 +- js/tmpl.min.js | 2 +- package.json | 90 ++++++++++++++++++++++++++------------------------ 7 files changed, 166 insertions(+), 87 deletions(-) create mode 100644 Gruntfile.js delete mode 100644 Makefile diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..f77fb6f --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,71 @@ +/* + * JavaScript Load Image Gruntfile + * https://github.com/blueimp/JavaScript-Load-Image + * + * Copyright 2013, Sebastian Tschan + * https://blueimp.net + * + * Licensed under the MIT license: + * http://www.opensource.org/licenses/MIT + */ + +/*global module */ + +module.exports = function (grunt) { + 'use strict'; + + grunt.initConfig({ + jshint: { + all: [ + 'Gruntfile.js', + 'js/compile.js', + 'js/demo.js', + 'js/runtime.js', + 'js/tmpl.js', + 'test/test.js' + ] + }, + simplemocha: { + options: { + ignoreLeaks: false, + ui: 'bdd', + reporter: 'spec' + }, + all: { + src: ['test/test.js'] + } + }, + mocha: { + all: { + src: ['test/index.html'], + options: { + run: true, + bail: true, + log: true, + reporter: 'Spec' + }, + mocha: { + ignoreLeaks: false + } + } + }, + uglify: { + production: { + src: [ + 'js/tmpl.js' + ], + dest: 'js/tmpl.min.js' + } + } + }); + + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-simple-mocha'); + grunt.loadNpmTasks('grunt-mocha'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-bump-build-git'); + + grunt.registerTask('test', ['jshint', 'simplemocha', 'mocha']); + grunt.registerTask('default', ['test', 'uglify']); + +}; diff --git a/Makefile b/Makefile deleted file mode 100644 index f8f58a1..0000000 --- a/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -.PHONY: js - -js: - node_modules/.bin/uglifyjs js/tmpl.js -c -m -o js/tmpl.min.js diff --git a/bower.json b/bower.json index 364ff05..3b631ce 100644 --- a/bower.json +++ b/bower.json @@ -1,39 +1,45 @@ { - "name": "blueimp-tmpl", - "version": "2.4.0", - "title": "JavaScript Templates", - "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.", - "keywords": [ - "javascript", - "templates", - "templating" - ], - "homepage": "https://github.com/blueimp/JavaScript-Templates", - "author": { - "name": "Sebastian Tschan", - "url": "https://blueimp.net/" - }, - "maintainers": [ - { - "name": "Sebastian Tschan", - "url": "https://blueimp.net/" - } - ], - "repository": { - "type": "git", - "url": "git://github.com/blueimp/JavaScript-Templates.git" - }, - "bugs": "https://github.com/blueimp/JavaScript-Templates/issues", - "licenses": [ - { - "type": "MIT", - "url": "http://www.opensource.org/licenses/MIT" - } - ], - "devDependencies": { - "mocha": "1.11.0", - "expect.js": "0.2.0", - "uglify-js": "2.3.6" - }, - "main": "js/tmpl.js" + "name": "blueimp-tmpl", + "version": "2.5.0", + "title": "JavaScript Templates", + "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.", + "keywords": [ + "javascript", + "templates", + "templating" + ], + "homepage": "https://github.com/blueimp/JavaScript-Templates", + "author": { + "name": "Sebastian Tschan", + "url": "https://blueimp.net/" + }, + "maintainers": [ + { + "name": "Sebastian Tschan", + "url": "https://blueimp.net/" + } + ], + "repository": { + "type": "git", + "url": "git://github.com/blueimp/JavaScript-Templates.git" + }, + "bugs": "https://github.com/blueimp/JavaScript-Templates/issues", + "licenses": [ + { + "type": "MIT", + "url": "http://www.opensource.org/licenses/MIT" + } + ], + "devDependencies": { + "mocha": "1.11.0", + "expect.js": "0.2.0", + "uglify-js": "2.3.6" + }, + "main": "js/tmpl.js", + "ignore": [ + "/*.*", + "css", + "js/demo.js", + "test" + ] } diff --git a/js/runtime.js b/js/runtime.js index 672fcc4..c4121fd 100644 --- a/js/runtime.js +++ b/js/runtime.js @@ -1,5 +1,5 @@ /* - * JavaScript Templates Runtime 2.4.0 + * JavaScript Templates Runtime 2.4.1 * https://github.com/blueimp/JavaScript-Templates * * Copyright 2011, Sebastian Tschan @@ -29,6 +29,7 @@ "'" : "'" }; tmpl.encode = function (s) { + /*jshint eqnull:true */ return (s == null ? "" : "" + s).replace( tmpl.encReg, function (c) { diff --git a/js/tmpl.js b/js/tmpl.js index bb3d4cd..9380053 100644 --- a/js/tmpl.js +++ b/js/tmpl.js @@ -1,5 +1,5 @@ /* - * JavaScript Templates 2.4.0 + * JavaScript Templates 2.4.1 * https://github.com/blueimp/JavaScript-Templates * * Copyright 2011, Sebastian Tschan @@ -66,6 +66,7 @@ "'" : "'" }; tmpl.encode = function (s) { + /*jshint eqnull:true */ return (s == null ? "" : "" + s).replace( tmpl.encReg, function (c) { diff --git a/js/tmpl.min.js b/js/tmpl.min.js index bd82354..64bb2a3 100644 --- a/js/tmpl.min.js +++ b/js/tmpl.min.js @@ -1 +1 @@ -!function(e){"use strict";var n=function(e,t){var c=/[^\w\-\.:]/.test(e)?new Function(n.arg+",tmpl","var _e=tmpl.encode"+n.helper+",_s='"+e.replace(n.regexp,n.func)+"';return _s;"):n.cache[e]=n.cache[e]||n(n.load(e));return t?c(t,n):function(e){return c(e,n)}};n.cache={},n.load=function(e){return document.getElementById(e).innerHTML},n.regexp=/([\s'\\])(?!(?:[^{]|\{(?!%))*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g,n.func=function(e,n,t,c,r,u){return n?{"\n":"\\n","\r":"\\r"," ":"\\t"," ":" "}[n]||"\\"+n:t?"="===t?"'+_e("+c+")+'":"'+("+c+"==null?'':"+c+")+'":r?"';":u?"_s+='":void 0},n.encReg=/[<>&"'\x00]/g,n.encMap={"<":"<",">":">","&":"&",'"':""","'":"'"},n.encode=function(e){return(null==e?"":""+e).replace(n.encReg,function(e){return n.encMap[e]||""})},n.arg="o",n.helper=",print=function(s,e){_s+=e?(s==null?'':s):_e(s);},include=function(s,d){_s+=tmpl(s,d);}","function"==typeof define&&define.amd?define(function(){return n}):e.tmpl=n}(this); \ No newline at end of file +!function(a){"use strict";var b=function(a,c){var d=/[^\w\-\.:]/.test(a)?new Function(b.arg+",tmpl","var _e=tmpl.encode"+b.helper+",_s='"+a.replace(b.regexp,b.func)+"';return _s;"):b.cache[a]=b.cache[a]||b(b.load(a));return c?d(c,b):function(a){return d(a,b)}};b.cache={},b.load=function(a){return document.getElementById(a).innerHTML},b.regexp=/([\s'\\])(?!(?:[^{]|\{(?!%))*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g,b.func=function(a,b,c,d,e,f){return b?{"\n":"\\n","\r":"\\r"," ":"\\t"," ":" "}[b]||"\\"+b:c?"="===c?"'+_e("+d+")+'":"'+("+d+"==null?'':"+d+")+'":e?"';":f?"_s+='":void 0},b.encReg=/[<>&"'\x00]/g,b.encMap={"<":"<",">":">","&":"&",'"':""","'":"'"},b.encode=function(a){return(null==a?"":""+a).replace(b.encReg,function(a){return b.encMap[a]||""})},b.arg="o",b.helper=",print=function(s,e){_s+=e?(s==null?'':s):_e(s);},include=function(s,d){_s+=tmpl(s,d);}","function"==typeof define&&define.amd?define(function(){return b}):a.tmpl=b}(this); \ No newline at end of file diff --git a/package.json b/package.json index 4525ccf..17925bc 100644 --- a/package.json +++ b/package.json @@ -1,45 +1,49 @@ { - "name": "blueimp-tmpl", - "version": "2.4.0", - "title": "JavaScript Templates", - "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.", - "keywords": [ - "javascript", - "templates", - "templating" - ], - "homepage": "https://github.com/blueimp/JavaScript-Templates", - "author": { - "name": "Sebastian Tschan", - "url": "https://blueimp.net/" - }, - "maintainers": [ - { - "name": "Sebastian Tschan", - "url": "https://blueimp.net/" - } - ], - "repository": { - "type": "git", - "url": "git://github.com/blueimp/JavaScript-Templates.git" - }, - "bugs": "https://github.com/blueimp/JavaScript-Templates/issues", - "licenses": [ - { - "type": "MIT", - "url": "http://www.opensource.org/licenses/MIT" - } - ], - "devDependencies": { - "mocha": "1.12.1", - "expect.js": "0.2.0", - "uglify-js": "2.4.0" - }, - "scripts": { - "test": "mocha --reporter spec" - }, - "bin": { - "tmpl.js": "js/compile.js" - }, - "main": "js/tmpl.js" + "name": "blueimp-tmpl", + "version": "2.5.0", + "title": "JavaScript Templates", + "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.", + "keywords": [ + "javascript", + "templates", + "templating" + ], + "homepage": "https://github.com/blueimp/JavaScript-Templates", + "author": { + "name": "Sebastian Tschan", + "url": "https://blueimp.net/" + }, + "maintainers": [ + { + "name": "Sebastian Tschan", + "url": "https://blueimp.net/" + } + ], + "repository": { + "type": "git", + "url": "git://github.com/blueimp/JavaScript-Templates.git" + }, + "bugs": "https://github.com/blueimp/JavaScript-Templates/issues", + "licenses": [ + { + "type": "MIT", + "url": "http://www.opensource.org/licenses/MIT" + } + ], + "devDependencies": { + "grunt": "~0.4.1", + "grunt-contrib-uglify": "~0.2.7", + "grunt-contrib-jshint": "~0.7.1", + "grunt-bump-build-git": "~1.0.0", + "grunt-simple-mocha": "~0.4.0", + "grunt-mocha": "~0.4.1", + "expect.js": "0.2.0" + }, + "scripts": { + "test": "grunt test" + }, + "bin": { + "tmpl.js": "js/compile.js" + }, + "main": "js/tmpl.js" } From 9eca5a304c2fc33606b306f4a02e85daf30f5da3 Mon Sep 17 00:00:00 2001 From: Sebastian Tschan Date: Mon, 11 Nov 2013 18:33:45 +0100 Subject: [PATCH 02/96] Removed unnecessary devDependencies from bower.json. --- bower.json | 7 +------ package.json | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/bower.json b/bower.json index 3b631ce..e5a56cd 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "blueimp-tmpl", - "version": "2.5.0", + "version": "2.5.1", "title": "JavaScript Templates", "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.", "keywords": [ @@ -30,11 +30,6 @@ "url": "http://www.opensource.org/licenses/MIT" } ], - "devDependencies": { - "mocha": "1.11.0", - "expect.js": "0.2.0", - "uglify-js": "2.3.6" - }, "main": "js/tmpl.js", "ignore": [ "/*.*", diff --git a/package.json b/package.json index 17925bc..524602a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blueimp-tmpl", - "version": "2.5.0", + "version": "2.5.1", "title": "JavaScript Templates", "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.", "keywords": [ From 9a1db7bb5dd9502009dcb051717cbb9094e40d34 Mon Sep 17 00:00:00 2001 From: Sebastian Tschan Date: Mon, 11 Nov 2013 18:39:20 +0100 Subject: [PATCH 03/96] Added PhantomJS check to test runner HTML page. --- bower.json | 2 +- package.json | 2 +- test/index.html | 8 +++++--- test/test.js | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index e5a56cd..312db1b 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "blueimp-tmpl", - "version": "2.5.1", + "version": "2.5.2", "title": "JavaScript Templates", "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.", "keywords": [ diff --git a/package.json b/package.json index 524602a..eeb05bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blueimp-tmpl", - "version": "2.5.1", + "version": "2.5.2", "title": "JavaScript Templates", "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.", "keywords": [ diff --git a/test/index.html b/test/index.html index 89f5391..5827909 100644 --- a/test/index.html +++ b/test/index.html @@ -1,7 +1,7 @@ - + - + diff --git a/js/compile.js b/js/compile.js index 84ff2ce..0bf0144 100755 --- a/js/compile.js +++ b/js/compile.js @@ -1,6 +1,6 @@ #!/usr/bin/env node /* - * JavaScript Templates Compiler 2.4.0 + * JavaScript Templates Compiler * https://github.com/blueimp/JavaScript-Templates * * Copyright 2011, Sebastian Tschan @@ -53,7 +53,7 @@ if (index > 1) { stats = fs.statSync(file); if (!stats.isFile()) { - console.error(file + ' is not a file.'); + console.error(file + " is not a file."); return; } content = fs.readFileSync(file, "utf8"); @@ -74,7 +74,7 @@ } }); if (!list.length) { - console.error('Missing input file.'); + console.error("Missing input file."); return; } // Combine the generated functions as cache of the minimal runtime: diff --git a/js/demo.js b/js/demo.js index afcedc2..2862415 100644 --- a/js/demo.js +++ b/js/demo.js @@ -1,5 +1,5 @@ /* - * JavaScript Templates Demo JS 2.4.0 + * JavaScript Templates Demo * https://github.com/blueimp/JavaScript-Templates * * Copyright 2013, Sebastian Tschan diff --git a/js/runtime.js b/js/runtime.js index c4121fd..cb4c27e 100644 --- a/js/runtime.js +++ b/js/runtime.js @@ -1,5 +1,5 @@ /* - * JavaScript Templates Runtime 2.4.1 + * JavaScript Templates Runtime * https://github.com/blueimp/JavaScript-Templates * * Copyright 2011, Sebastian Tschan @@ -9,10 +9,10 @@ * http://www.opensource.org/licenses/MIT */ -/*jslint sloppy: true */ /*global define */ (function ($) { + "use strict"; var tmpl = function (id, data) { var f = tmpl.cache[id]; return data ? f(data, tmpl) : function (data) { diff --git a/js/tmpl.js b/js/tmpl.js index 9380053..90b9e42 100644 --- a/js/tmpl.js +++ b/js/tmpl.js @@ -1,5 +1,5 @@ /* - * JavaScript Templates 2.4.1 + * JavaScript Templates * https://github.com/blueimp/JavaScript-Templates * * Copyright 2011, Sebastian Tschan @@ -12,7 +12,7 @@ * http://ejohn.org/blog/javascript-micro-templating/ */ -/*jslint evil: true, regexp: true, unparam: true */ +/*jshint evil: true */ /*global document, define */ (function ($) { @@ -21,7 +21,7 @@ var f = !/[^\w\-\.:]/.test(str) ? tmpl.cache[str] = tmpl.cache[str] || tmpl(tmpl.load(str)) : new Function( - tmpl.arg + ',tmpl', + tmpl.arg + ",tmpl", "var _e=tmpl.encode" + tmpl.helper + ",_s='" + str.replace(tmpl.regexp, tmpl.func) + "';return _s;" diff --git a/test/index.html b/test/index.html index 9bdd78b..5be1e78 100644 --- a/test/index.html +++ b/test/index.html @@ -1,7 +1,7 @@ JavaScript Templates Demo - +

JavaScript Templates Demo

-

< 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.

+

1KB lightweight, fast & powerful JavaScript templating engine with zero dependencies.
+Compatible with server-side environments like Node.js, module loaders like RequireJS, Browserify or webpack and all web browsers.