linkedin / linkedin/dustjs

Context helpers does not work with conditionals

Open
#693 3 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

The dustjs manual at http://www.dustjs.com/guides/context-helpers/#writing-context-helpers insinuates that context helpers can be used with both sections (`{#helper}`) and conditionals (`{?helper}`). However, conditionals only seem to test truthy/falsy... thus always returning true for functions/helpers.

the following code always console.logs `

? PASS

`.

```
var data = {
helper: function() {
return false;
}
}

var src = '

{#helper}# PASS!{/helper}

{?helper}? PASS{/helper}

';

dust.renderSource(src, data, function(err, html) {
console.log(html);
})
```

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 by reproducing the example with dust.renderSource from the issue and compare the documented context-helper behavior for sections and conditionals at the linked DustJS manual page. Trace how conditional helpers are evaluated, then add regression coverage showing the helper's returned false value is respected and verify the rendered output.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.