Closed kyleaclark closed 10 years ago
Without the updates shown above to app.js the following error in the browser is returned:
Error: The partial partialTest could not be found at new Error (unknown source) at Error.Exception (/Users/kclark/git_repo/hepcfight/node_modules/handlebars/dist/cjs/handlebars/exception.js:6:41) at Object.invokePartial (/Users/kclark/git_repo/hepcfight/node_modules/handlebars/dist/cjs/handlebars/runtime.js:135:11) at Object.invokePartialWrapper as invokePartial at Object.eval (eval at
Without the updates shown above to app.js the following error in the terminal console is returned:
Error: The partial partialTest could not be found at new Error (unknown source) at Error.Exception (/Users/kclark/git_repo/hepcfight/node_modules/handlebars/dist/cjs/handlebars/exception.js:6:41) at Object.invokePartial (/Users/kclark/git_repo/hepcfight/node_modules/handlebars/dist/cjs/handlebars/runtime.js:135:11) at Object.invokePartialWrapper as invokePartial at Object.eval (eval at
(/Users/kclark/git_repo/hepcfight/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:179:23)) at /Users/kclark/git_repo/hepcfight/node_modules/handlebars/dist/cjs/handlebars/runtime.js:92:31 at /Users/kclark/git_repo/hepcfight/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:467:21 at Function.exports.handlebars.render (/Users/kclark/git_repo/hepcfight/node_modules/consolidate/lib/consolidate.js:495:14) at /Users/kclark/git_repo/hepcfight/node_modules/consolidate/lib/consolidate.js:144:25 at /Users/kclark/git_repo/hepcfight/node_modules/consolidate/lib/consolidate.js:97:5 GET / 500 60ms - 1.14kb
I'll make a pull request for the suggested update above.
Resolved by #11
Handlebars views/partials does not appear to be set up by default in the express generation. Here is an example of what I implemented to utilize partials via handlebars:
/* app.js */
// Variable defintions var fs = require('fs'); var hbs = require('handlebars'); var partials = "./views/partials/";
// Register partials fs.readdirSync(partials).forEach(function (file) { var source = fs.readFileSync(partials + file, "utf8"), partial = /(.+).html/.exec(file).pop();
hbs.registerPartial(partial, source); });
/* views / index.html */
{{> partialTest}}
/* views / partials / partialTest.html */
Partial test content