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
Error when passing an argument to a non-existing template helper #4230
Comments
Thanks for the feature request! We welcome discussions about how to make Meteor better. If you haven't yet, check out our wiki page about feature requests on GitHub. This is working as intended, but we could relax the error if there is strong agreement that the "I said there was going to be a function but there wasn't but who cares" semantics is better. |
Maybe I am just used to it from Django. The issue is that this can break at runtime into end-users faces. I do not think there can be a strong agreement though. This is like strict vs. dynamic type checking debate. It depends on the taste. :-) Maybe the difference could be that in production it does not blow up, during development it does. |
The issue is that you cannot really "catch" those errors and display something else instead. Or suppress it. That could be also one option. That you could register a template rendering error handler and decide in there what to do. You could return another template to render. Or you could just rethrow. |
This issue has been moved to meteor/blaze#217 - closing here. Thanks! |
There is big difference between:
And:
When
foo
does not even exist as a template helper/in data context.The first one does not return anything, the second one throws
Uncaught Error: Can't call non-function: null
(it is not even captures by Blaze).I think none of those should throw an error (or there should be a debug switch for all of missing template helpers to throw an error). There is no much difference between calling
foo.bar()
andfoo.bar('test')
in my opinion.I would really love if spacebars would work like CoffeeScript. That this would be
foo?.bar 'test'
. So iffoo
does not exist, it should simply not continue.Now I have to make for each such case a helper, which does
foo?.bar
for me. Or wrap the thing into{{#if foo}}...{{/if}}
.The text was updated successfully, but these errors were encountered: