* stringify `contents` on the original file data
This commit is contained in:
Ian Storm Taylor 2014-02-07 10:00:47 -08:00
parent 71a790621c
commit 388c30ecda
3 changed files with 14 additions and 8 deletions

View file

@ -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

View file

@ -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();
});
}

View file

@ -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": {