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

No error on non-existent partial #1219

Closed
pmendelski opened this issue May 8, 2016 · 9 comments
Closed

No error on non-existent partial #1219

pmendelski opened this issue May 8, 2016 · 9 comments

Comments

@pmendelski
Copy link

Why there is no information if I try to use a non-existent partial?
Example: https://jsfiddle.net/mendlik/7boebcan/1/

@jbboehr
Copy link
Contributor

jbboehr commented May 17, 2016

The mustache spec requires an unset partial to be rendered as an empty string: https://github.com/mustache/spec/blob/master/specs/partials.yml#L24

@pmendelski
Copy link
Author

Ok, thanks.
I just think it is not very helpful during development.
Simple warning log would be a blessing.

@jbboehr
Copy link
Contributor

jbboehr commented May 20, 2016

Maybe it would make sense to throw an error for an unregistered partial when strict: true is passed, if it doesn't already?

@jbboehr
Copy link
Contributor

jbboehr commented May 20, 2016

@mendlik It looks like a regular partial is supposed to trigger an error if undefined: https://github.com/wycats/handlebars.js/blob/v4.0.5/spec/partials.js#L95-L100

@jbboehr
Copy link
Contributor

jbboehr commented May 20, 2016

@mendlik It looks like that's the expected behaviour of a partial block: http://handlebarsjs.com/partials.html

The normal behavior when attempting to render a partial that is not found is for the implementation to throw an error. If failover is desired instead, partials may be called using the block syntax.

{{#> myPartial }}
  Failover content
{{/myPartial}}

@pmendelski
Copy link
Author

pmendelski commented May 23, 2016

Thanks for your insight.
However I think it is a little bit misleading because the same paragraph says:

This block syntax may also be used to pass templates to the partial, which can be executed by the specially named partial, @partial-block.

Don't you think that having an optional partial is not as popular feature as using layouts?
Nevertheless thank you for your time.

@WestonThayer
Copy link

WestonThayer commented May 24, 2016

Agree with @mendlik, the docs shouldn't encourage you to use a partial block in the @partial-block sense if it's not going to throw an error, or at least a warning.

@olsonpm
Copy link

olsonpm commented Apr 13, 2017

I'm pretty sure I just got hit by this.

The issue is that the syntax is the same for failover partials and layouts. That's just bad design because it leaves intent ambiguous from the compiler's perspective.

@nknapp
Copy link
Collaborator

nknapp commented Apr 5, 2020

Closing due to inactivity. If this is still important to you, please comment.

@nknapp nknapp closed this as completed Apr 5, 2020
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

5 participants