From 2cb8429dcfd6f6649a33d521afe17dd59e6d7d83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Kluth?= Date: Wed, 2 Mar 2016 20:22:04 +0100 Subject: [PATCH 01/10] bump deps --- package.json | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 7b62470..2a2b9f5 100644 --- a/package.json +++ b/package.json @@ -24,16 +24,16 @@ "node": ">= 0.10.0" }, "dependencies": { - "dust": "^0.3.0", - "dustjs-linkedin": "^2.4.0", - "gulp-util": "^3.0.0", - "libxmljs": "^0.14.1", - "lodash": "^2.4.1", - "q": "^1.0.1", - "svg-sprite-data": "^2.0.0", - "svgo": "^0.5.0", - "through2": "^0.4.1", - "vinyl": "^0.2.3" + "dust": "0.3.0", + "dustjs-linkedin": "2.7.2", + "gulp-util": "3.0.7", + "libxmljs": "0.17.1", + "lodash": "4.6.0", + "q": "1.4.1", + "svg-sprite-data": "2.0.0", + "svgo": "0.6.1", + "through2": "2.0.1", + "vinyl": "1.1.1" }, "keywords": [ "svg", @@ -41,18 +41,18 @@ "gulpplugin" ], "devDependencies": { - "chai": "~1.9.0", - "gulp": "^3.8.6", - "gulp-clean": "^0.3.1", - "gulp-contribs": "0.0.2", - "gulp-filter": "^0.5.0", - "gulp-jshint": "~1.4.0", - "gulp-svg2png": "^0.3.0", - "gulp-yuidoc": "^0.1.2", - "img-compare": "^1.2.0", - "marked": "^0.3.2", - "mocha": "~1.18.0", - "sinon": "~1.8.2", - "vinyl-fs": "^0.1.4" + "chai": "3.5.0", + "gulp": "3.9.1", + "gulp-clean": "0.3.1", + "gulp-contribs": "0.0.3", + "gulp-filter": "4.0.0", + "gulp-jshint": "2.0.0", + "gulp-svg2png": "1.0.0", + "gulp-yuidoc": "0.1.2", + "img-compare": "1.2.0", + "marked": "0.3.5", + "mocha": "2.4.5", + "sinon": "1.17.3", + "vinyl-fs": "2.3.4" } } From a475b35a1b549af84799a21c6a7de4867fd24085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Kluth?= Date: Wed, 2 Mar 2016 20:22:44 +0100 Subject: [PATCH 02/10] get rid of rust && use lodash for templating --- index.js | 35 ++++++++++++++++------------------- tmpl/preview-symbol.html | 27 ++++++++++++++------------- tmpl/preview.html | 39 ++++++++++++++++++++++----------------- tmpl/sprite.css | 36 +++++++++++++++++++++--------------- 4 files changed, 73 insertions(+), 64 deletions(-) diff --git a/index.js b/index.js index d75d868..c5fd598 100755 --- a/index.js +++ b/index.js @@ -2,19 +2,11 @@ var SpriteData = require("svg-sprite-data"); var through2 = require("through2"); var gutil = require("gulp-util"); var File = gutil.File; -var dust = require("dustjs-linkedin"); var fs = require("fs"); var Q = require("q"); var _ = require("lodash"); var path = require("path"); -/** - * Make Dust templates retain whitespace - * @param ctx - * @param node - * @returns {*} - */ -dust.optimizers.format = function(ctx, node) { return node; }; var PLUGIN_NAME = "gulp-svg-sprites"; @@ -350,20 +342,25 @@ function makeFile(template, fileName, stream, data) { var deferred = Q.defer(); var id = _.uniqueId(); + var out = ''; + + try{ + var compiled = _.template(template); + out = compiled(data); + }catch(e){ + deferred.reject(e); + return deferred.promise; + } - dust.compileFn(template, id, false); - - dust.render(id, data, function (err, out) { - stream.push(new File({ - cwd: "./", - base: "./", - path: fileName, - contents: new Buffer(out) - })); + stream.push(new File({ + cwd: "./", + base: "./", + path: fileName, + contents: new Buffer(out) + })); - deferred.resolve(out); - }); + deferred.resolve(out); return deferred.promise; } diff --git a/tmpl/preview-symbol.html b/tmpl/preview-symbol.html index 769df48..2a40ca5 100644 --- a/tmpl/preview-symbol.html +++ b/tmpl/preview-symbol.html @@ -8,7 +8,7 @@ Icon kit preview | gulp-svg-sprites - +