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.
Pass:
Fail:
output:
So "../prefix" expression when it was put into "if" can't walk up to the root.