From d18013b8547ca93118d58916313cd45441d6b640 Mon Sep 17 00:00:00 2001 From: Adrien Date: Wed, 2 Mar 2016 16:55:07 +0200 Subject: [PATCH 1/8] removed minification uglifyJS can cause issues that break the main function of compile.js and prevent writing out a file. --- js/compile.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/compile.js b/js/compile.js index 8fda899..a1381ee 100755 --- a/js/compile.js +++ b/js/compile.js @@ -78,6 +78,12 @@ } // Combine the generated functions as cache of the minimal runtime: code = runtime.replace('{}', '{' + list.join(',') + '}') - // Generate the minified code and print it to the console output: - console.log(uglifyJS.minify(code, {fromString: true}).code) + // Write the cmpiled code to an arbitrary outfile: + fs.writeFile(path.join(__dirname, 'compiled_template.js'), code, function(err) { + if(err) { + return console.log(err); + } + + console.log("The file was saved successfully."); + }); }()) From 4c3cc6f55250964d3c15a8823f16416d46b49a1b Mon Sep 17 00:00:00 2001 From: Adrien Date: Wed, 2 Mar 2016 16:55:56 +0200 Subject: [PATCH 2/8] removed dependancy on uglify-js --- js/compile.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/compile.js b/js/compile.js index a1381ee..2742195 100755 --- a/js/compile.js +++ b/js/compile.js @@ -17,7 +17,6 @@ var path = require('path') var tmpl = require(path.join(__dirname, 'tmpl.js')) var fs = require('fs') - var uglifyJS = require('uglify-js') // Retrieve the content of the minimal runtime: var runtime = fs.readFileSync(path.join(__dirname, 'runtime.js'), 'utf8') // A regular expression to parse templates from script tags in a HTML page: From 4cc374d49b2e51c5b375b9d107c3358e5ca6140c Mon Sep 17 00:00:00 2001 From: Adrien Date: Wed, 2 Mar 2016 17:00:13 +0200 Subject: [PATCH 3/8] Update compile.js --- js/compile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/compile.js b/js/compile.js index 2742195..66c0723 100755 --- a/js/compile.js +++ b/js/compile.js @@ -77,7 +77,7 @@ } // Combine the generated functions as cache of the minimal runtime: code = runtime.replace('{}', '{' + list.join(',') + '}') - // Write the cmpiled code to an arbitrary outfile: + // Write the compiled code to an arbitrary outfile: fs.writeFile(path.join(__dirname, 'compiled_template.js'), code, function(err) { if(err) { return console.log(err); From bc1d5b3254ddbddc4d9cf2074f064da196a4f224 Mon Sep 17 00:00:00 2001 From: Adrien Date: Wed, 2 Mar 2016 17:08:56 +0200 Subject: [PATCH 4/8] removed mentions of minification --- README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d74e2a0..9ab29bb 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ loaders like RequireJS, Browserify or webpack and all web browsers. ## Usage ### Client-side -Include the (minified) JavaScript Templates script in your HTML markup: +Include the JavaScript Templates script in your HTML markup: ```html @@ -354,19 +354,17 @@ The JavaScript Templates project comes with a compilation script, that allows you to compile your templates into JavaScript code and combine them with a minimal Templates runtime into one minified JavaScript file. -The compilation script is built for [node.js](http://nodejs.org/) and also -requires [UglifyJS](https://github.com/mishoo/UglifyJS). -To use it, first install both the JavaScript Templates project and UglifyJS via +The compilation script is built for [node.js](http://nodejs.org/). +To use it, first install the JavaScript Templates project via [npm](https://www.npmjs.org/): ```sh -npm install uglify-js blueimp-tmpl +npm install blueimp-tmpl ``` -This will put the executables **uglifyjs** and **tmpl.js** into the folder -**node_modules/.bin**. It will also make them available on your PATH if you -install the packages globally -(by adding the **-g** flag to the install command). +This will put the executable **tmpl.js** into the folder +**node_modules/.bin**. It will also make it available on your PATH if you +install the packages globally (by adding the **-g** flag to the install command). The **tmpl.js** executable accepts the paths to one or multiple template files as command line arguments and prints the generated JavaScript code to the From 9e869740d10f61cdb892c6e898f5f0883e9c7bf2 Mon Sep 17 00:00:00 2001 From: Adrien Date: Wed, 2 Mar 2016 17:11:40 +0200 Subject: [PATCH 5/8] Update README.md --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9ab29bb..6e51fcb 100644 --- a/README.md +++ b/README.md @@ -367,12 +367,10 @@ This will put the executable **tmpl.js** into the folder install the packages globally (by adding the **-g** flag to the install command). The **tmpl.js** executable accepts the paths to one or multiple template files -as command line arguments and prints the generated JavaScript code to the -console output. The following command line shows you how to store the generated -code in a new JavaScript file that can be included in your project: +as command line arguments and saves the generated JavaScript code to a file named **compiled_template.js** in the current directory: ```sh -tmpl.js templates/upload.html templates/download.html > tmpl.min.js +tmpl.js templates/upload.html templates/download.html ``` The files given as command line arguments to **tmpl.js** can either be pure From 499978af19ce5e81aab30b0427943aa935342adf Mon Sep 17 00:00:00 2001 From: Adrien Date: Thu, 3 Mar 2016 09:41:51 +0200 Subject: [PATCH 6/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6e51fcb..095b163 100644 --- a/README.md +++ b/README.md @@ -367,7 +367,7 @@ This will put the executable **tmpl.js** into the folder install the packages globally (by adding the **-g** flag to the install command). The **tmpl.js** executable accepts the paths to one or multiple template files -as command line arguments and saves the generated JavaScript code to a file named **compiled_template.js** in the current directory: +as command line arguments and saves the generated JavaScript code to a file named **compiled_template.js** in the current working directory: ```sh tmpl.js templates/upload.html templates/download.html From 279c7fd3d031afcc662953cc3ece764800fb5468 Mon Sep 17 00:00:00 2001 From: Adrien Date: Thu, 3 Mar 2016 09:42:28 +0200 Subject: [PATCH 7/8] Update compile.js --- js/compile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/compile.js b/js/compile.js index 66c0723..a4f978d 100755 --- a/js/compile.js +++ b/js/compile.js @@ -78,7 +78,7 @@ // Combine the generated functions as cache of the minimal runtime: code = runtime.replace('{}', '{' + list.join(',') + '}') // Write the compiled code to an arbitrary outfile: - fs.writeFile(path.join(__dirname, 'compiled_template.js'), code, function(err) { + fs.writeFile(path.join(process.cwd(), 'output.js'), code, function(err) { if(err) { return console.log(err); } From b5d60f6170c72fa391cd8efbf4cce06b4d5c4b5f Mon Sep 17 00:00:00 2001 From: Adrien Date: Thu, 3 Mar 2016 09:58:27 +0200 Subject: [PATCH 8/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 095b163..3b796fc 100644 --- a/README.md +++ b/README.md @@ -367,7 +367,7 @@ This will put the executable **tmpl.js** into the folder install the packages globally (by adding the **-g** flag to the install command). The **tmpl.js** executable accepts the paths to one or multiple template files -as command line arguments and saves the generated JavaScript code to a file named **compiled_template.js** in the current working directory: +as command line arguments and saves the generated JavaScript code to **output.js** in the current working directory: ```sh tmpl.js templates/upload.html templates/download.html