linkedin / linkedin/dustjs

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

Open
#765 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2.9k
Forks
461
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Context.prototype._get and reproduce the report with article.html and the html-head partial, using the stated Node.js and dustjs versions if available. Check how missing references are reported and how the current context is selected. Done means the originating template is identified correctly and missing references follow a defined error behavior rather than being silently logged.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.