question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using the Block and Content wth ExpressJS and express-handlebars

See original GitHub issue

Hi, I am wanting to use the block and content helpers to inject items from my partials to slots in other partials or the base layout file that includes html,head, body etc. I require it straight after handlebars-helpers

var exphbs  = require('express-handlebars');
var hbsHelpers = require('handlebars-helpers');

in my main.hbs template I have the following near the closing body tag

{{{block "test"}}}

and on a partial page I have

{{#content "test" mode="append"}}
blah blah blah
{{/content}}

But when I run up the page it fails to load and I am presented with the following error

Error: Missing helper: "block"
   at Object.<anonymous> (/Users/custa/github/Portfolio/portfolioapp/node_modules/express-handlebars/node_modules/handlebars/dist/cjs/handlebars/base.js:86:13)
   at Object.eval (eval at createFunctionContext (/Users/custa/github/Portfolio/portfolioapp/node_modules/express-handlebars/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:221:23), <anonymous>:21:72)
   at ret (/Users/custa/github/Portfolio/portfolioapp/node_modules/express-handlebars/node_modules/handlebars/dist/cjs/handlebars/runtime.js:159:30)
   at ret (/Users/custa/github/Portfolio/portfolioapp/node_modules/express-handlebars/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:488:21)
   at ExpressHandlebars._renderTemplate (/Users/custa/github/Portfolio/portfolioapp/node_modules/express-handlebars/lib/express-handlebars.js:247:12)
   at ExpressHandlebars.<anonymous> (/Users/custa/github/Portfolio/portfolioapp/node_modules/express-handlebars/lib/express-handlebars.js:173:21)
   at wrappedPromise.linkTransaction (/Users/custa/github/Portfolio/portfolioapp/node_modules/newrelic/lib/instrumentation/core/globals.js:147:23)
   at wrappedPromise.wrapped [as __NR_wrapper] (/Users/custa/github/Portfolio/portfolioapp/node_modules/newrelic/lib/transaction/tracer/index.js:157:28)
   at wrappedHandler (/Users/custa/github/Portfolio/portfolioapp/node_modules/newrelic/lib/instrumentation/core/globals.js:175:26)

Not sure what I am doing wrong, do I have to somehow register the helpers? Anybody got any thoughts?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
aplatov76commented, Mar 12, 2019

nu i xyinya

0reactions
kplatova97commented, Nov 12, 2020

Hello, show me your code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handlebars With Node.js & Express - Tutorial For ... - YouTube
A beginner's guide to handlebars and how to use it with your node. js and express apps. Handlebars is one of the most...
Read more >
Node.js + Express - Tutorial - Handlebars Templating Engine
Part of a complete node. js series, including the usage of Express. js and much more!This video introduces you to the Handlebars templating ......
Read more >
Create Website With Handlebars Express - NodeJS - Geekstrick
In this tutorial, we will see how to Create a Website With Express Handlebars – NodeJS. With the handlebar-express, we can create a...
Read more >
Guide to Handlebars: Templating Engine for Node/JavaScript
In this article, we are going to take a look at how to use the Handlebars template engine with Node.js and Express.
Read more >
A Step By Step Guide To Using Handlebars With Your Node js ...
Let's Get Our Hands Dirty · npm init. After filling the necessary information, we need to install express of course by typing the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found