Skip to content

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

@evil-shrike

Description

@evil-shrike

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions