Giter VIP home page Giter VIP logo

metalsmith-hbs-relative-partial's People

Contributors

citizenjasona avatar jsonberry avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

metalsmith-hbs-relative-partial's Issues

cannot reproduce example

After many try that failed, I try to reproduce your example, so I copied the directory structure the main template src/index.hbs and the partial src/about/components heading.hbs. I wrote an index.js like this

var Metalsmith = require('metalsmith');
var partials = require('metalsmith-hbs-relative-partial');
var inplace = require('metalsmith-in-place');

Metalsmith(__dirname)
    .source('./src')
    .destination('./build')
    .use(partials({
        dirName: 'components'
    }))
    .use(inplace())
    .build(function (err) {
        // For error handling
        if (err) {
            throw err;
        }
    });

and when I execute this code with node v8.9.3 I get

$ node index.js

/home/marc/metaltest/index.js:15
            throw err;
            ^
Error: The partial about/heading could not be found
    at Object.invokePartial (/home/marc/metaltest/node_modules/jstransformer-handlebars/node_modules/handlebars/dist/cjs/handlebars/runtime.js:281:11)
    at Object.invokePartialWrapper [as invokePartial] (/home/marc/metaltest/node_modules/jstransformer-handlebars/node_modules/handlebars/dist/cjs/handlebars/runtime.js:68:39)
    at Object.eval [as main] (eval at createFunctionContext (/home/marc/metaltest/node_modules/jstransformer-handlebars/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), <anonymous>:5:31)
    at main (/home/marc/metaltest/node_modules/jstransformer-handlebars/node_modules/handlebars/dist/cjs/handlebars/runtime.js:175:32)
    at Object.ret (/home/marc/metaltest/node_modules/jstransformer-handlebars/node_modules/handlebars/dist/cjs/handlebars/runtime.js:178:12)
    at Object.ret [as fn] (/home/marc/metaltest/node_modules/jstransformer-handlebars/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:526:21)
    at Transformer.render (/home/marc/metaltest/node_modules/metalsmith-in-place/node_modules/jstransformer/index.js:289:25)
    at resolve (/home/marc/metaltest/node_modules/metalsmith-in-place/lib/index.js:60:33)
    at new Promise (<anonymous>)
    at render (/home/marc/metaltest/node_modules/metalsmith-in-place/lib/index.js:29:10)

The versions of package I use is

  "dependencies": {
    "jstransformer-handlebars": "^1.1.0",
    "metalsmith": "^2.3.0",
    "metalsmith-in-place": "^4.1.1",
    "metalsmith-jstransformer": "^0.13.0"
  }

You say that this plugin is aimed to be used with metalsmith-in-place, which has had a major change with version 2.0 the 2017-01-01, when it adopted jstransformer. As your plugin is from march 2017, I have assumed it rely on metalsmith-in-place greater than 2.0, but as there is presently no test data, and so metalsmith-in-place is not in your package.json, there is no way (except go through the code!) to know the targeted version.

What about this error, in which context your example is working?

Create gate for file not existing

There should be a gate for a file not existing

Along the lines of:

if (invalidFile(file)) {
    throw new Error('file is invalid');
}

what might be more appropriate here is allowing the plugin to gracefully exit if no file is found

Create gate for directory name

There should be a gate for the listed directory name not existing

Along the lines of:

if (invalidDirName(dirName)) {
    throw new Error('directory name is invalid');
}

Create gate for source

There should be a gate for the listed source directory not existing

Along the lines of:

if (invalidSource(source)) {
    throw new Error('source is invalid');
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.