From 43a2d0dda9b0dcbc2ad6f954343b9ea18a86d918 Mon Sep 17 00:00:00 2001 From: Mayo Jordanov Date: Sat, 30 Aug 2014 23:06:49 -0700 Subject: [PATCH 1/6] Add support for template inheritance from content There is no common way of specifying blocks, so the patterns are specified by user. See extends test cases for example use. --- lib/index.js | 61 +++++++++++++++++- .../extends-def_block/build/index.html | 12 ++++ .../expected/.index.html.swo | Bin 0 -> 12288 bytes .../expected/.index.html.swp | Bin 0 -> 12288 bytes .../extends-def_block/expected/index.html | 12 ++++ .../fixtures/extends-def_block/src/index.html | 6 ++ .../extends-def_block/templates/base.html | 11 ++++ .../extends-def_extends/build/index.html | 15 +++++ .../expected/.index.html.swp | Bin 0 -> 12288 bytes .../extends-def_extends/expected/index.html | 15 +++++ .../extends-def_extends/src/index.html | 11 ++++ .../extends-def_extends/templates/base.html | 11 ++++ test/fixtures/extends/build/index.html | 15 +++++ test/fixtures/extends/expected/index.html | 15 +++++ test/fixtures/extends/src/index.html | 12 ++++ test/fixtures/extends/templates/base.html | 11 ++++ test/index.js | 49 +++++++++++++- 17 files changed, 252 insertions(+), 4 deletions(-) create mode 100644 test/fixtures/extends-def_block/build/index.html create mode 100644 test/fixtures/extends-def_block/expected/.index.html.swo create mode 100644 test/fixtures/extends-def_block/expected/.index.html.swp create mode 100644 test/fixtures/extends-def_block/expected/index.html create mode 100644 test/fixtures/extends-def_block/src/index.html create mode 100644 test/fixtures/extends-def_block/templates/base.html create mode 100644 test/fixtures/extends-def_extends/build/index.html create mode 100644 test/fixtures/extends-def_extends/expected/.index.html.swp create mode 100644 test/fixtures/extends-def_extends/expected/index.html create mode 100644 test/fixtures/extends-def_extends/src/index.html create mode 100644 test/fixtures/extends-def_extends/templates/base.html create mode 100644 test/fixtures/extends/build/index.html create mode 100644 test/fixtures/extends/expected/index.html create mode 100644 test/fixtures/extends/src/index.html create mode 100644 test/fixtures/extends/templates/base.html diff --git a/lib/index.js b/lib/index.js index b3bfd98..1776f2b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -7,6 +7,8 @@ var join = require('path').join; var match = require('multimatch'); var omit = require('lodash.omit'); +var util = require('util'); + /** * Expose `plugin`. */ @@ -17,7 +19,7 @@ module.exports = plugin; * Settings. */ -var settings = ['engine', 'directory', 'pattern', 'inPlace', 'default']; +var settings = ['engine', 'directory', 'pattern', 'inPlace', 'default', 'useExtends', 'defaultExtends', 'defaultBlock']; /** * Metalsmith plugin to run files through any template in a template `dir`. @@ -28,6 +30,11 @@ var settings = ['engine', 'directory', 'pattern', 'inPlace', 'default']; * @property {String} engine * @property {String} inPlace (optional) * @property {String} pattern (optional) + * @property {Boolean} useExtends (optional) + * @property {String} defaultExtends (optional) + * @property {String} defaultBlock (optional) + * @property {String} extendsPattern (optional) + * @property {String} blockPattern (optional) * @return {Function} */ @@ -41,6 +48,29 @@ function plugin(opts){ var pattern = opts.pattern; var inPlace = opts.inPlace; var def = opts.default; + + var useExtends = opts.useExtends; + var defaultExtends = opts.defaultExtends; + var defaultBlock = opts.defaultBlock; + var extendsPattern = opts.extendsPattern; + var blockPattern = opts.blockPattern; + + if ((defaultExtends || defaultBlock) && !useExtends) { + throw new Error('"useExtends" option required to use defaultExtends or defaultBlock'); + } + + if (useExtends && !extendsPattern) { + throw new Error('"extendsPattern" required with "useExtends"'); + } + + if (useExtends && defaultBlock && !blockPattern) { + throw new Error('"blockPattern" required with "useExtends" and "defaultBlock"'); + } + + if (blockPattern && !(Array.isArray(blockPattern) && blockPattern.length >= 1)) { + throw new Error('"blockPattern" must be an array with at least one element (block opening pattern).'); + } + var params = omit(opts, settings); return function(files, metalsmith, done){ @@ -49,8 +79,10 @@ function plugin(opts){ function check(file){ var data = files[file]; var tmpl = data.template || def; + var ext = useExtends ? data.extends || defaultExtends : false; + if (pattern && !match(file, pattern)[0]) return false; - if (!inPlace && !tmpl) return false; + if (!inPlace && !tmpl && !ext) return false; return true; } @@ -74,6 +106,29 @@ function plugin(opts){ if (inPlace) { str = clone.contents; render = consolidate[engine].render; + + } else if (useExtends) { + if (useExtends) { + clone.extends = data.extends || defaultExtends; + //fake a filename, make it in templates directory, so rest of templates + //in inheritance chain can be resolves + clone.filename = metalsmith.join(dir, clone.extends); + } + + str = util.format(extendsPattern, clone.extends); + + if (defaultBlock) { + str += util.format(blockPattern[0], defaultBlock); + } + + str += clone.contents; + + if (defaultBlock && blockPattern.length > 1) { + str += util.format(blockPattern[1], defaultBlock); + } + + render = consolidate[engine].render; + } else { str = metalsmith.join(dir, data.template || def); render = consolidate[engine]; @@ -87,4 +142,4 @@ function plugin(opts){ }); } }; -} \ No newline at end of file +} diff --git a/test/fixtures/extends-def_block/build/index.html b/test/fixtures/extends-def_block/build/index.html new file mode 100644 index 0000000..52501cd --- /dev/null +++ b/test/fixtures/extends-def_block/build/index.html @@ -0,0 +1,12 @@ + + +TITLE + + + +CONTENT here + + + diff --git a/test/fixtures/extends-def_block/expected/.index.html.swo b/test/fixtures/extends-def_block/expected/.index.html.swo new file mode 100644 index 0000000000000000000000000000000000000000..7bba362710af189c9e72522aa19138cddcc58cdc GIT binary patch literal 12288 zcmeI&Jx{_w7zgkNTs6LZ0o1{%9KIwtTv!YPiJ~#p)fDbXD=j7TA%R7|fcgz|bky0z z&Cyjyzl58cPo*v-=xq33^6&Mz-u30THEpAGQrj<-i`yh^fvEhLcia8-nMH>v@`iCb z{8zIM_{=srQITaYOrn5&hi%jiJ+_IGuxbSZ?)Rj!1GXKL zIL5Y48*=uxjC5tOH7e*BJ1F`b{c^#{w}K-Om@a`nx160h+S=SGr4PQgx>8tPI-V{A zJS_wu009U<00Izz00gF7fV(-m5QBW?Fq`$cu|6x&K>z{}fB*y_009U<00Izz00bcL z4+T6!bTm(ND@niq|GfWyO8p^um%K?{B`=a^$&=(kaxb})q-$>^*ODvAr34KE5P$## zAOHafKmY;|fB*y_0D%btTC4Pj_6lj$h|RDvUK8ye)ZJ>`E%>%)Nq3hkm#;OM5lfNqY0 zlfHqDzJ!~bCv9AW>L!%_1OMFI+>?*{+b&6?cv3yEb_!dh+dR?Ub=G;}wV8!HQRoh$ zd$u<6i(H5SUhho;35jv$VOfUQ7s9SC*}%#p7w!z`P*<0SG_< z0uX=z1RyY#0@BIQh0Z*i&VDX!Ge6q2iv|J^fB*y_009U<00Izz00bZafe93FJ)&)0 z^j{_mfBpXdz5f5ygAdKS=1udedC@#;9yJe|d(EBZR&%4d(hTo2fev_O2tWV=5P$## zAOHafKmY;|fWW^A*e3b2y+pQYMBbo8R6eXZm6~Im^mO3 + +TITLE + + + +CONTENT here + + + diff --git a/test/fixtures/extends-def_block/src/index.html b/test/fixtures/extends-def_block/src/index.html new file mode 100644 index 0000000..d0ed88c --- /dev/null +++ b/test/fixtures/extends-def_block/src/index.html @@ -0,0 +1,6 @@ +--- +title: TITLE +content: CONTENT +extends: base.html +--- +{{ content }} here diff --git a/test/fixtures/extends-def_block/templates/base.html b/test/fixtures/extends-def_block/templates/base.html new file mode 100644 index 0000000..6596d53 --- /dev/null +++ b/test/fixtures/extends-def_block/templates/base.html @@ -0,0 +1,11 @@ + + +{{ title }} + + + +{% block content %}{% endblock %} + + diff --git a/test/fixtures/extends-def_extends/build/index.html b/test/fixtures/extends-def_extends/build/index.html new file mode 100644 index 0000000..741ff86 --- /dev/null +++ b/test/fixtures/extends-def_extends/build/index.html @@ -0,0 +1,15 @@ + + +TITLE + + + + +CONTENT here + + + diff --git a/test/fixtures/extends-def_extends/expected/.index.html.swp b/test/fixtures/extends-def_extends/expected/.index.html.swp new file mode 100644 index 0000000000000000000000000000000000000000..50b14e419ff931167441aedcdc277f0d0dc861a2 GIT binary patch literal 12288 zcmeI&y-LGS6bJCrI*VT~5Ooj=?X6$v5W19t1+7A(dumQ;Bxy=>3hkm#;OM5lfNqY0 zlfHqDzJ!~bCv9AW>L!%_1OMFI+>?*{+b&6?cv3yEb_!dh+dR?Ub=G;}wV8!HQRoh$ zd$u<6i(H5SUhho;35jv$VOfUQ7s9SC*}%#p7w!z`P*<0SG_< z0uX=z1RyY#0@BIQh0Z*i&VDX!Ge6q2iv|J^fB*y_009U<00Izz00bZafe93FJ)&)0 z^j{_mfBpXdz5f5ygAdKS=1udedC@#;9yJe|d(EBZR&%4d(hTo2fev_O2tWV=5P$## zAOHafKmY;|fWW^A*e3b2y+pQYMBbo8R6eXZm6~Im^mO3 + +TITLE + + + + +CONTENT here + + + diff --git a/test/fixtures/extends-def_extends/src/index.html b/test/fixtures/extends-def_extends/src/index.html new file mode 100644 index 0000000..c689679 --- /dev/null +++ b/test/fixtures/extends-def_extends/src/index.html @@ -0,0 +1,11 @@ +--- +title: TITLE +content: CONTENT +--- +{% block css %} +/* CSS here */ +{% endblock %} + +{% block content %} +{{ content }} here +{% endblock %} diff --git a/test/fixtures/extends-def_extends/templates/base.html b/test/fixtures/extends-def_extends/templates/base.html new file mode 100644 index 0000000..6596d53 --- /dev/null +++ b/test/fixtures/extends-def_extends/templates/base.html @@ -0,0 +1,11 @@ + + +{{ title }} + + + +{% block content %}{% endblock %} + + diff --git a/test/fixtures/extends/build/index.html b/test/fixtures/extends/build/index.html new file mode 100644 index 0000000..741ff86 --- /dev/null +++ b/test/fixtures/extends/build/index.html @@ -0,0 +1,15 @@ + + +TITLE + + + + +CONTENT here + + + diff --git a/test/fixtures/extends/expected/index.html b/test/fixtures/extends/expected/index.html new file mode 100644 index 0000000..741ff86 --- /dev/null +++ b/test/fixtures/extends/expected/index.html @@ -0,0 +1,15 @@ + + +TITLE + + + + +CONTENT here + + + diff --git a/test/fixtures/extends/src/index.html b/test/fixtures/extends/src/index.html new file mode 100644 index 0000000..c0d27fc --- /dev/null +++ b/test/fixtures/extends/src/index.html @@ -0,0 +1,12 @@ +--- +title: TITLE +content: CONTENT +extends: base.html +--- +{% block css %} +/* CSS here */ +{% endblock %} + +{% block content %} +{{ content }} here +{% endblock %} diff --git a/test/fixtures/extends/templates/base.html b/test/fixtures/extends/templates/base.html new file mode 100644 index 0000000..6596d53 --- /dev/null +++ b/test/fixtures/extends/templates/base.html @@ -0,0 +1,11 @@ + + +{{ title }} + + + +{% block content %}{% endblock %} + + diff --git a/test/index.js b/test/index.js index ed788fe..24d0967 100644 --- a/test/index.js +++ b/test/index.js @@ -85,4 +85,51 @@ describe('metalsmith-templates', function(){ done(); }); }); -}); \ No newline at end of file + + it('should extend templates', function(done){ + Metalsmith('test/fixtures/extends') + .use(templates({ + engine: 'swig', + useExtends: true, + extendsPattern: '{% extends "%s" %}' + })) + .build(function(err){ + if (err) return done(err); + equal('test/fixtures/extends/expected', 'test/fixtures/extends/build'); + done(); + }); + }); + + it('should extend using default block', function(done){ + Metalsmith('test/fixtures/extends-def_block') + .use(templates({ + engine: 'swig', + useExtends: true, + defaultBlock: 'content', + extendsPattern: '{% extends "%s" %}', + blockPattern: [ '{% block %s %}', '{% endblock %}' ] + })) + .build(function(err){ + if (err) return done(err); + equal('test/fixtures/extends-def_block/expected', 'test/fixtures/extends-def_block/build'); + done(); + }); + + }); + + it('should extend using default extends', function(done){ + Metalsmith('test/fixtures/extends-def_extends') + .use(templates({ + engine: 'swig', + useExtends: true, + defaultExtends: 'base.html', + extendsPattern: '{% extends "%s" %}' + })) + .build(function(err){ + if (err) return done(err); + equal('test/fixtures/extends-def_extends/expected', 'test/fixtures/extends-def_extends/build'); + done(); + }); + }); + +}); From 92e217a158edf3ce9c25c0e020a04e764de68670 Mon Sep 17 00:00:00 2001 From: Mayo Jordanov Date: Sun, 31 Aug 2014 01:05:09 -0700 Subject: [PATCH 2/6] Improve options Make useExtends required only when using defaultExtends. This allows for mixing normal template use with extends --- lib/index.js | 26 +++++++++++++------------- test/index.js | 4 +--- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/index.js b/lib/index.js index 1776f2b..9b20d6b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -55,7 +55,7 @@ function plugin(opts){ var extendsPattern = opts.extendsPattern; var blockPattern = opts.blockPattern; - if ((defaultExtends || defaultBlock) && !useExtends) { + if ((defaultExtends) && !useExtends) { throw new Error('"useExtends" option required to use defaultExtends or defaultBlock'); } @@ -63,7 +63,7 @@ function plugin(opts){ throw new Error('"extendsPattern" required with "useExtends"'); } - if (useExtends && defaultBlock && !blockPattern) { + if (defaultBlock && !blockPattern) { throw new Error('"blockPattern" required with "useExtends" and "defaultBlock"'); } @@ -79,7 +79,7 @@ function plugin(opts){ function check(file){ var data = files[file]; var tmpl = data.template || def; - var ext = useExtends ? data.extends || defaultExtends : false; + var ext = useExtends || data.extends ? data.extends || defaultExtends : false; if (pattern && !match(file, pattern)[0]) return false; if (!inPlace && !tmpl && !ext) return false; @@ -103,17 +103,13 @@ function plugin(opts){ var str; var render; - if (inPlace) { - str = clone.contents; - render = consolidate[engine].render; + if (useExtends || clone.extends) { + if (!extendsPattern) throw new Error('"extendsPattern" option required with extends'); - } else if (useExtends) { - if (useExtends) { - clone.extends = data.extends || defaultExtends; - //fake a filename, make it in templates directory, so rest of templates - //in inheritance chain can be resolves - clone.filename = metalsmith.join(dir, clone.extends); - } + clone.extends = data.extends || defaultExtends; + //fake a filename, make it in templates directory, so rest of templates + //in inheritance chain can be resolves + clone.filename = metalsmith.join(dir, clone.extends); str = util.format(extendsPattern, clone.extends); @@ -129,6 +125,10 @@ function plugin(opts){ render = consolidate[engine].render; + } else if (inPlace) { + str = clone.contents; + render = consolidate[engine].render; + } else { str = metalsmith.join(dir, data.template || def); render = consolidate[engine]; diff --git a/test/index.js b/test/index.js index 24d0967..b931d39 100644 --- a/test/index.js +++ b/test/index.js @@ -90,7 +90,6 @@ describe('metalsmith-templates', function(){ Metalsmith('test/fixtures/extends') .use(templates({ engine: 'swig', - useExtends: true, extendsPattern: '{% extends "%s" %}' })) .build(function(err){ @@ -100,11 +99,10 @@ describe('metalsmith-templates', function(){ }); }); - it('should extend using default block', function(done){ + it('should extend using default block', function(done){ Metalsmith('test/fixtures/extends-def_block') .use(templates({ engine: 'swig', - useExtends: true, defaultBlock: 'content', extendsPattern: '{% extends "%s" %}', blockPattern: [ '{% block %s %}', '{% endblock %}' ] From be3d8e2cc843827b7f7129a646f34ee09d72eb37 Mon Sep 17 00:00:00 2001 From: Mayo Jordanov Date: Sun, 31 Aug 2014 01:06:22 -0700 Subject: [PATCH 3/6] Remove undesired swap files --- .../extends-def_block/expected/.index.html.swo | Bin 12288 -> 0 bytes .../extends-def_block/expected/.index.html.swp | Bin 12288 -> 0 bytes .../expected/.index.html.swp | Bin 12288 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 test/fixtures/extends-def_block/expected/.index.html.swo delete mode 100644 test/fixtures/extends-def_block/expected/.index.html.swp delete mode 100644 test/fixtures/extends-def_extends/expected/.index.html.swp diff --git a/test/fixtures/extends-def_block/expected/.index.html.swo b/test/fixtures/extends-def_block/expected/.index.html.swo deleted file mode 100644 index 7bba362710af189c9e72522aa19138cddcc58cdc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI&Jx{_w7zgkNTs6LZ0o1{%9KIwtTv!YPiJ~#p)fDbXD=j7TA%R7|fcgz|bky0z z&Cyjyzl58cPo*v-=xq33^6&Mz-u30THEpAGQrj<-i`yh^fvEhLcia8-nMH>v@`iCb z{8zIM_{=srQITaYOrn5&hi%jiJ+_IGuxbSZ?)Rj!1GXKL zIL5Y48*=uxjC5tOH7e*BJ1F`b{c^#{w}K-Om@a`nx160h+S=SGr4PQgx>8tPI-V{A zJS_wu009U<00Izz00gF7fV(-m5QBW?Fq`$cu|6x&K>z{}fB*y_009U<00Izz00bcL z4+T6!bTm(ND@niq|GfWyO8p^um%K?{B`=a^$&=(kaxb})q-$>^*ODvAr34KE5P$## zAOHafKmY;|fB*y_0D%btTC4Pj_6lj$h|RDvUK8ye)ZJ>`E%>%)Nq3hkm#;OM5lfNqY0 zlfHqDzJ!~bCv9AW>L!%_1OMFI+>?*{+b&6?cv3yEb_!dh+dR?Ub=G;}wV8!HQRoh$ zd$u<6i(H5SUhho;35jv$VOfUQ7s9SC*}%#p7w!z`P*<0SG_< z0uX=z1RyY#0@BIQh0Z*i&VDX!Ge6q2iv|J^fB*y_009U<00Izz00bZafe93FJ)&)0 z^j{_mfBpXdz5f5ygAdKS=1udedC@#;9yJe|d(EBZR&%4d(hTo2fev_O2tWV=5P$## zAOHafKmY;|fWW^A*e3b2y+pQYMBbo8R6eXZm6~Im^mO33hkm#;OM5lfNqY0 zlfHqDzJ!~bCv9AW>L!%_1OMFI+>?*{+b&6?cv3yEb_!dh+dR?Ub=G;}wV8!HQRoh$ zd$u<6i(H5SUhho;35jv$VOfUQ7s9SC*}%#p7w!z`P*<0SG_< z0uX=z1RyY#0@BIQh0Z*i&VDX!Ge6q2iv|J^fB*y_009U<00Izz00bZafe93FJ)&)0 z^j{_mfBpXdz5f5ygAdKS=1udedC@#;9yJe|d(EBZR&%4d(hTo2fev_O2tWV=5P$## zAOHafKmY;|fWW^A*e3b2y+pQYMBbo8R6eXZm6~Im^mO3 Date: Sun, 31 Aug 2014 01:33:50 -0700 Subject: [PATCH 4/6] Content template filename Use a "filename" that's a non-existent file within the template directory, to avoid circular inheritance --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 9b20d6b..fc84048 100644 --- a/lib/index.js +++ b/lib/index.js @@ -109,7 +109,7 @@ function plugin(opts){ clone.extends = data.extends || defaultExtends; //fake a filename, make it in templates directory, so rest of templates //in inheritance chain can be resolves - clone.filename = metalsmith.join(dir, clone.extends); + clone.filename = metalsmith.join(dir, file + "-" + clone.extends); str = util.format(extendsPattern, clone.extends); From b306a2962bd56a45ffa83588b9e670fcb1070619 Mon Sep 17 00:00:00 2001 From: Mayo Jordanov Date: Sat, 4 Oct 2014 00:12:26 -0700 Subject: [PATCH 5/6] Remove build directories --- test/fixtures/basic/build/index.html | 6 ------ test/fixtures/default/build/default.md | 3 --- test/fixtures/default/build/other.md | 2 -- test/fixtures/directory/build/index.html | 6 ------ test/fixtures/metadata/build/one.html | 9 --------- test/fixtures/metadata/build/two.html | 9 --------- test/fixtures/pattern/build/index.html | 2 -- test/fixtures/pattern/build/index.md | 3 --- 8 files changed, 40 deletions(-) delete mode 100644 test/fixtures/basic/build/index.html delete mode 100644 test/fixtures/default/build/default.md delete mode 100644 test/fixtures/default/build/other.md delete mode 100644 test/fixtures/directory/build/index.html delete mode 100644 test/fixtures/metadata/build/one.html delete mode 100644 test/fixtures/metadata/build/two.html delete mode 100644 test/fixtures/pattern/build/index.html delete mode 100644 test/fixtures/pattern/build/index.md diff --git a/test/fixtures/basic/build/index.html b/test/fixtures/basic/build/index.html deleted file mode 100644 index 78d253f..0000000 --- a/test/fixtures/basic/build/index.html +++ /dev/null @@ -1,6 +0,0 @@ - - - -body - - \ No newline at end of file diff --git a/test/fixtures/default/build/default.md b/test/fixtures/default/build/default.md deleted file mode 100644 index 825c4df..0000000 --- a/test/fixtures/default/build/default.md +++ /dev/null @@ -1,3 +0,0 @@ -Title - -Body \ No newline at end of file diff --git a/test/fixtures/default/build/other.md b/test/fixtures/default/build/other.md deleted file mode 100644 index 385984a..0000000 --- a/test/fixtures/default/build/other.md +++ /dev/null @@ -1,2 +0,0 @@ - -Body \ No newline at end of file diff --git a/test/fixtures/directory/build/index.html b/test/fixtures/directory/build/index.html deleted file mode 100644 index 78d253f..0000000 --- a/test/fixtures/directory/build/index.html +++ /dev/null @@ -1,6 +0,0 @@ - - - -body - - \ No newline at end of file diff --git a/test/fixtures/metadata/build/one.html b/test/fixtures/metadata/build/one.html deleted file mode 100644 index d89b2e4..0000000 --- a/test/fixtures/metadata/build/one.html +++ /dev/null @@ -1,9 +0,0 @@ - - - Local Title - - - -one - - \ No newline at end of file diff --git a/test/fixtures/metadata/build/two.html b/test/fixtures/metadata/build/two.html deleted file mode 100644 index 9307d56..0000000 --- a/test/fixtures/metadata/build/two.html +++ /dev/null @@ -1,9 +0,0 @@ - - - Global Title - - - -two - - \ No newline at end of file diff --git a/test/fixtures/pattern/build/index.html b/test/fixtures/pattern/build/index.html deleted file mode 100644 index 525c2ac..0000000 --- a/test/fixtures/pattern/build/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Not matched body \ No newline at end of file diff --git a/test/fixtures/pattern/build/index.md b/test/fixtures/pattern/build/index.md deleted file mode 100644 index b11dae2..0000000 --- a/test/fixtures/pattern/build/index.md +++ /dev/null @@ -1,3 +0,0 @@ -Matched - -Matched body \ No newline at end of file From f4d93f06b13361e0c03fabc9937ee6b8af98812e Mon Sep 17 00:00:00 2001 From: Mayo Jordanov Date: Sat, 4 Oct 2014 00:21:04 -0700 Subject: [PATCH 6/6] Fix paths for Metalsmith 1.x --- lib/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index f83bb0c..8f313df 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5,6 +5,7 @@ var each = require('async').each; var extend = require('extend'); var match = require('multimatch'); var omit = require('lodash.omit'); +var path = require('path'); var util = require('util'); @@ -108,7 +109,7 @@ function plugin(opts){ clone.extends = data.extends || defaultExtends; //fake a filename, make it in templates directory, so rest of templates //in inheritance chain can be resolves - clone.filename = metalsmith.join(dir, file + "-" + clone.extends); + clone.filename = path.join(metalsmith.directory(), dir, file + "-" + clone.extends); str = util.format(extendsPattern, clone.extends);