Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helpers and Handlebars.SafeString #7

Open
michaellopez opened this issue Jan 11, 2015 · 1 comment
Open

Helpers and Handlebars.SafeString #7

michaellopez opened this issue Jan 11, 2015 · 1 comment

Comments

@michaellopez
Copy link

I ran into two problems with writing my own helpers in ./helpers.

First of all I would like to overwrite the helpers in Broccoli Taco. This line is preventing me from it. I would much rather have the helpers from Broccoli Taco be defaults that I can overwrite if I wanted to. I understand you want to enforce a consistent API and functionality but I believe that when users helpers are not overwriting the "built-in" ones users get confused, like me :)

It is not that big of a deal naming my helpers something else, I just thought I would ask to see if you would be willing to change it.

Secondly, I cannot see that it is documented anywhere that to make any helpers, that return HTML, work properly with Handlebars.SafeString you have to use var Handlebars = require('broccoli-taco/node_modules/handlebars'). Otherwise you end up with your own instance of Handlebars and Handlebars.SafeString that will not match the one used inside Broccoli Taco.

I guess there is an instanceof check or similar inside Handlebars for the SafeString mechanism that makes an instance of Handlebars.SafeString from one Handlebars instance not work with another.

I doubt think could be improved but at least it could be documented better to save other people the time I put in to find the cause. So either use var Handlebars = require('broccoli-taco/node_modules/handlebars') or "triple-stash" ({{{my-helper}}}) for helpers created by users, both will work.

@moudy
Copy link
Owner

moudy commented Jan 22, 2015

@michaellopez thanks for the input. I think being able to overwrite the default helpers is ok. I need to look into the Handlebars.SafeString issue more but using var Handlebars = require('broccoli-taco/node_modules/handlebars') seems like an ok short term fix.

I'll try to fix this soon. Pull request are always welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants