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

Expression "../" inside "#if" can't exit "#with" context #601

Closed
evil-shrike opened this issue Aug 14, 2013 · 2 comments
Closed

Expression "../" inside "#if" can't exit "#with" context #601

evil-shrike opened this issue Aug 14, 2013 · 2 comments

Comments

@evil-shrike
Copy link

Pass:

  describe('#with', function() {
    it("with", function() {
      var string = "{{#with person}}{{../prefix}} {{first}} {{last}}{{/with}}";
      shouldCompileTo(string, {person: {first: "Alan", last: "Johnson"}, prefix: "Mr."}, "Mr. Alan Johnson");
    });
  });

Fail:

  describe('#with', function() {
    it("with", function() {
      var string = "{{#with person}}{{#if hasPrefix}}{{../prefix}}.{{/if}} {{first}} {{last}}{{/with}}";
      shouldCompileTo(string, {person: {hasPrefix: true, first: "Alan", last: "Johnson"}, prefix: "Mr"}, "Mr. Alan Johnson");
    });
  });

output:

  1) builtin helpers #with with:                                                                           

      actual expected                                                                                      

      Mr. Alan Johnson                                                                                     

   expected '. Alan Johnson' to equal 'Mr. Alan Johnson' | 'Mr. Alan Johnson' should === '. Alan Johnson'

So "../prefix" expression when it was put into "if" can't walk up to the root.

@kpdecker
Copy link
Collaborator

Both helpers create their own context's so you need to do ../../ to push up to the top. There is a bit of discussion on this over at #392.

Closing for now to keep things consolidated on #392 but please let me know if ../../ still fails.

@evil-shrike
Copy link
Author

"../.." works, thanks.
It's really matter of nesting context in block helpers.

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