Can't figured out how to register handlebars-helper and other single helpers
See original GitHub issueHi, I’m trying to register handlebars-helper, handlebars-helper-repeat and a custom dump helper.
This is my last attempt:
const extra_helpers = require('handlebars-helpers')();
const repeat = require('handlebars-helper-repeat');
const hbs = require('@frctl/handlebars')({
helpers: {
repeat,
dump: function(str) {
return JSON.stringify(str);
},
extra_helpers
},
});
fractal.components.engine(hbs);
fractal.docs.engine(hbs);
The error thrown, when I try to use, for example, ‘{{#contains …}}’ is:
ERROR RENDERING COMPONENT
Missing helper: "contains"
For me handlebars-helper works only alone defined like this:
const helpers = require('handlebars-helpers')();
const hbs = require('@frctl/handlebars')({
helpers
});
fractal.components.engine(hbs);
fractal.docs.engine(hbs);
Can you help me?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
can't register handlebar helpers - Stack Overflow
You should register the Handlebar helpers. Posting my full code: const express = require('express'); const exphbs ...
Read more >Built-in Helpers - Handlebars
You can write any helper and use it in a sub-expression. For example, in checking for initialization of a variable the built-in #if...
Read more >Create Custom Helper - Express Handlebars - #10 - YouTube
Step by step video on how to create custom helper with Express HandlebarsInterested in ... Your browser can't play this video. Learn more....
Read more >10 Handlebars training: Custom Helpers Part 1 - Expressions
Your browser can't play this video. Learn more. Switch camera.
Read more >Helpers in Handlebars.java
There are two way of registering helpers in Handlebars.java: Registering one ... Now you know how to register a helper, let's see what...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
extra_helpers
is an object, when you do this:You actually do this:
To make all those helpers available to your templates, you need to put them at the root of the
helpers
object. To do so, you can use the object spread syntax (Node ≥ 8.6):If you use an earlier version of Node, you can use
Object.assign
instead:// EDIT: nevermind, i have no clue what happend. but right now everything works.
hej @LeBenLeBen ,
thanks for your help! i restarted it of course but i got an error on my page, thats its not able to export the url:
(this error occur only when i try to use handlebar helpers, which are not there. so the panel-notes.nunj is fine)
my used versions:
the variable extraHelpers is defined with all the functions. but the engine has all the helpers added
console.log(fractal.docs.engine(hbs))
:i don’t know if the “helper missing” stuff related to my issue. but i think we are using the same handlebar & fractal version, right?