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

Unable to use {#} inside of {@select} due to lost context #50

Closed
omnipenguin opened this issue Jul 24, 2013 · 4 comments · Fixed by #107
Closed

Unable to use {#} inside of {@select} due to lost context #50

omnipenguin opened this issue Jul 24, 2013 · 4 comments · Fixed by #107

Comments

@omnipenguin
Copy link

Example code:

Dust:

{@select key=lix_key}
  {@eq value="D"}
    {emails|js}
    {@contextDump key="current" to="console"/}
    {#emails.suggestedProfiles}
      {name}  
    {/emails.suggestedProfiles}
  {/eq}
...
{/select}

When trying to iterate using {#} within a {@select} block, the context appears to be lost. The iteration simply does not happen, even though the JSON object exists and is valid.
The object ({emails} in the example) when printed is perfectly fine and valid.
However when the current context is dumped within one of the {@eq} blocks, all that is outputted is:

JSON:

{
  "isSelect": true,
  "isResolved": true,
  "selectKey": "D"
}

This leads me to believe the current context is lost and thus the iteration doesn't happen. Removing the {@select} block makes everything work properly.

@jimmyhchan
Copy link
Contributor

Please remove the internal link. It's meaningless on github.

Also please simplify example to highlight the issue

@omnipenguin
Copy link
Author

Sorry about that. I updated my OP and cleaned up the code a bit. It's an extremely simplified version of the code I was working with.

@jimmyhchan
Copy link
Contributor

This is actually the same as #9 and #42.

Possible fixes:

  • use {#email}{#suggestedProfile}{name}{/suggestedProfile}{/email} which does not have dots and will not be affected by this bug.
    • change @select to push under the current context head the same way paritials parameters are currently being handled
  • wait for the latest Dust core release that will change how paths are resolved.

@rragan
Copy link
Contributor

rragan commented Jul 24, 2013

The latest dust release is out there now. 2.0.0 and has the path change

sethkinast pushed a commit to sethkinast/dustjs-helpers that referenced this issue Dec 11, 2014
- Must be contained in a {@select} block
- Renders its body if any truth test inside the {@select} block evaluates to true
- Can be included multiple times inside a {@select} block.

As part of this change, {@select} no longer clobbers the current context, so keys that begin with a dot work inside a {@select}. This closes LinkedInAttic#9, closes LinkedInAttic#42, closes LinkedInAttic#50, and closes LinkedInAttic#79.
sethkinast pushed a commit to sethkinast/dustjs-helpers that referenced this issue Dec 13, 2014
- Must be contained in a {@select} block
- Renders its body if any truth test inside the {@select} block evaluates to true
- Can be included multiple times inside a {@select} block.

As part of this change, {@select} no longer clobbers the current context, so keys that begin with a dot work inside a {@select}. This closes LinkedInAttic#9, closes LinkedInAttic#42, closes LinkedInAttic#50, and closes LinkedInAttic#79.
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

Successfully merging a pull request may close this issue.

3 participants