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

How to keep unspecified variables in handlebars? #1220

Closed
TheInvoker opened this issue May 12, 2016 · 1 comment
Closed

How to keep unspecified variables in handlebars? #1220

TheInvoker opened this issue May 12, 2016 · 1 comment

Comments

@TheInvoker
Copy link

In handlebars, I have this code

<p>
    {{A}}
    {{B}}
</p>

and then I compile with

{"A" : "test"}

However the end result is

<p>
    test
</p>

But what I really want is:

<p>
    test
    {{B}}
</p>

Since B was not defined in the object, I want the variable text to remain. Is there a flag I can pass to the compile or some function to specify this behavior?

Thanks

@nknapp
Copy link
Collaborator

nknapp commented May 16, 2017

You specific case can be solved with the helperMissing helper.

https://jsfiddle.net/vva7musq/18/

It does not work anymore though, if you use {{a.x}} with dots in it, because that cannot be interpreted as helper call. I'd say there is no other way of doing that.

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