diff --git a/History.md b/History.md index ce80448..f3cf2c2 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,8 @@ +0.0.5 - February 7, 2013 +------------------------ +* stringify `contents` on the original file data + 0.0.4 - February 6, 2013 ------------------------ * switch to `extend` from `defaults` to avoid cloning diff --git a/lib/index.js b/lib/index.js index ae2d484..fc40e87 100644 --- a/lib/index.js +++ b/lib/index.js @@ -28,17 +28,19 @@ function plugin(opts){ each(Object.keys(files), convert, done); function convert(file, done){ + debug('checking file: %s', file); + var data = files[file]; + if (!data.template) return done(); + debug('converting file: %s', file); - var data = extend({}, metadata, files[file]); - var template = data.template; - if (!template) return done(); - var tmpl = metalsmith.join(opts.dir, template); - debug('stringify file: %s', file); data.contents = data.contents.toString(); - consolidate[opts.engine](tmpl, data, function(err, str){ + var tmpl = metalsmith.join(opts.dir, data.template); + var clone = extend({}, metadata, data); + + consolidate[opts.engine](tmpl, clone, function(err, str){ if (err) return done(err); + data.contents = new Buffer(str); debug('converted file: %s', file); - files[file].contents = new Buffer(str); done(); }); } diff --git a/package.json b/package.json index 015585d..86f349e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "metalsmith-templates", "description": "A metalsmith plugin to render files with templates.", "repository": "git://github.com/segmentio/metalsmith-templates.git", - "version": "0.0.4", + "version": "0.0.5", "license": "MIT", "main": "lib/index.js", "dependencies": {