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

2.7.5: "Context.prototype._get" prints wrong error when property/reference not found in context; should throw error, not only log #765

Open
thomas-mindruptive opened this issue Mar 12, 2017 · 5 comments

Comments

@thomas-mindruptive
Copy link

nodejs 7.4.0
dustjs 2.7.5

Template "article.html":

<head>
    {>html-head/}
    <meta name="keywords" content="{properties.category-x}">
    <meta name="author" content="{properties.author}">
</head>

The property "properties.category-x" does not exist in the given context. So the error is in template "article.html" but dust says: "Cannot find reference {properties.category-x} in template html-head".
So maybe dust uses the latest context (html-head partial) instead of the current one?
This makes it very hard to pin down errors in case of may templates.

  1. dustjs swallows the missing reference, it just logs it in "Context.prototype._get". This is very error prone and makes errors hard to find. A missing property is usually a typo or other error in the template. Could you add an option to dustjs to throw an error in such a case?

Thanks a lot
Tom

@jimmyhchan
Copy link
Contributor

Likely related to #755

@thomas-mindruptive
Copy link
Author

Thanks, exactly!
The second issue: Is it possible to add an option to throw errors when properties are not found in the context, e.g. "{properties.category-x}".
Thanks

@thomas-mindruptive
Copy link
Author

Hi, I just wanted to follow up with @jimmyhchan to ask if there are any plans to add the option to throw an error in case of a property not found in context. I would really help to build more reliable templates because a missing property usually means an error or typo in the template. Otherwise you miss a lot of potential problems during build-time.
Thanks a lot
Thomas

@thomas-mindruptive
Copy link
Author

Are there any news on this topic?
Thanks a lot!

@jimmyhchan
Copy link
Contributor

see this comment #757 (comment)

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