Comparing version 0.1.0 to 0.1.1
36
index.js
@@ -83,3 +83,3 @@ 'use strict'; | ||
var errmsg = ""; | ||
try { | ||
@@ -90,16 +90,32 @@ var data = {}; | ||
} | ||
} catch (err) { | ||
errmsg = "[gulp-tpl.html error: " + datafile + "] " + err; | ||
} | ||
if (fs.existsSync(hbsfile)) { | ||
var tpl = fs.readFileSync(hbsfile, 'utf8'); | ||
file.contents = new Buffer(Handlebars.compile(tpl)(data)); | ||
} else if (fs.existsSync(ejsfile)) { | ||
var tpl = fs.readFileSync(ejsfile, 'utf8'); | ||
file.contents = new Buffer(ejs.render(tpl, data)); | ||
if (errmsg==="") { | ||
var tplname = name; | ||
try { | ||
if (fs.existsSync(hbsfile)) { | ||
tplname += ".hbs"; | ||
var tpl = fs.readFileSync(hbsfile, 'utf8'); | ||
file.contents = new Buffer(Handlebars.compile(tpl)(data)); | ||
} else if (fs.existsSync(ejsfile)) { | ||
tplname += ".ejs"; | ||
var tpl = fs.readFileSync(ejsfile, 'utf8'); | ||
file.contents = new Buffer(ejs.render(tpl, data)); | ||
} | ||
} catch (err) { | ||
errmsg = "[gulp-tpl.html error: " + dirname + tplname + "] " + err; | ||
} | ||
} | ||
file.path = htmlfile; | ||
} catch (err) { | ||
this.emit('error', new gutil.PluginError('gulp-tpl.html', err)); | ||
if (errmsg!="") { | ||
if (options.ignoreErr) { | ||
gutil.log(errmsg); | ||
} else { | ||
this.emit('error', new gutil.PluginError('gulp-tpl.html', errmsg)); | ||
} | ||
} | ||
file.path = htmlfile; | ||
this.push(file); | ||
@@ -106,0 +122,0 @@ cb(); |
{ | ||
"name": "gulp-tpl", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "(handlebars/ejs) + yaml -> html", | ||
@@ -5,0 +5,0 @@ "author": "changkong <changkong012@gmail.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4386
107