Comparing version
23
index.js
@@ -33,3 +33,8 @@ var path = require('path') | ||
function add(name, string){ | ||
// The file arg is used to track the origin of the template | ||
// manually added templates should not be read so se need a way to check | ||
// and skip the fs.readFile call | ||
function add(name, string, file){ | ||
// TODO: throw if args are bad | ||
var beardo = this | ||
@@ -46,2 +51,4 @@ , template | ||
template.name = name | ||
template.file = file | ||
beardo.templates[name] = template | ||
@@ -55,5 +62,7 @@ | ||
template.name = name | ||
template.file = file | ||
beardo.templates[name] = template | ||
return beardo.templates[name] | ||
return template | ||
} | ||
@@ -76,3 +85,9 @@ } | ||
beardo.read(name, done) | ||
// check if this template has been added already and isn't a file | ||
// which would mean it needs to be read. | ||
if (beardo.templates[name] && ! beardo.templates[name].file) { | ||
done(null, beardo.templates[name]) | ||
} else { | ||
beardo.read(name, done) | ||
} | ||
@@ -119,3 +134,3 @@ function done(err, template){ | ||
var template = beardo.add(name, data) | ||
var template = beardo.add(name, data, file) | ||
, partials = scan(data) | ||
@@ -122,0 +137,0 @@ , queue = [] |
{ | ||
"name": "beardo", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"homepage": "https://github.com/jxson/beardo/", | ||
@@ -5,0 +5,0 @@ "bugs": "https://github.com/jxson/beardo/issues", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
7074
7.33%175
7.36%0
-100%