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

Strict mode has seemingly no effect on partials #1708

Open
3 of 4 tasks
JemarJones opened this issue Aug 26, 2020 · 4 comments
Open
3 of 4 tasks

Strict mode has seemingly no effect on partials #1708

JemarJones opened this issue Aug 26, 2020 · 4 comments
Labels

Comments

@JemarJones
Copy link

Before filing issues, please check the following points first:

This will probably help you to get a solution faster.
For bugs, it would be great to have a PR with a failing test-case.

The issue:

When using strict mode and passing a parameter into a partial, no error is thrown when that value is missing.

Example

See this running example here: https://runkit.com/jemarjones/handlebars-strict-mode-partials

const Handlebars = require("handlebars");
Handlebars.registerPartial('myPartial', 'Hello {{name}}')
const template = Handlebars.compile('{{>myPartial name=name}}', {strict: true})
console.log(template({name: 'World'})) // 'Hello World' 
// ^ Good, makes sense.

console.log(template({})) // 'Hello ' 
// ^ This should be throwing an error

const template2 = Handlebars.compile('{{name}}', {strict: true})
console.log(template2({})) // "name" not defined in [object Object] 
// ^ Not the best error message, but it does work when the missing value is used in the base template at least.
@JemarJones
Copy link
Author

Can anyone confirm whether this is as intended or whether you are open to changing this behaviour?

@EyePulp
Copy link

EyePulp commented Sep 30, 2020

@JemarJones I'm seeing the same behavior, and it has been throwing me off in my unit tests. I had assumed partials were beholden to strict behavior as well, but that appears to have been a bad assumption.

Thanks for the narrow example highlighting the issue.

@EyePulp
Copy link

EyePulp commented Sep 30, 2020

@JemarJones one more followup - I opened this issue a while ago: #1681 which talks about wanting to get more detail when a partial throws an error in strict mode. What I don't remember now is why/how I was able to get those errors identified in that issue to display, because now I don't seem to see them from partials.

@JemarJones
Copy link
Author

@JemarJones one more followup - I opened this issue a while ago: #1681 which talks about wanting to get more detail when a partial throws an error in strict mode. What I don't remember now is why/how I was able to get those errors identified in that issue to display, because now I don't seem to see them from partials.

Oh interesting, it would be awesome if there is some workaround possible

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

No branches or pull requests

3 participants