dustjs
dustjs copied to clipboard
2.7.5: "Context.prototype._get" prints wrong error when property/reference not found in context; should throw error, not only log
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.
- 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
Likely related to #755
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
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
Are there any news on this topic? Thanks a lot!
see this comment https://github.com/linkedin/dustjs/issues/757#issuecomment-327928472