-
Notifications
You must be signed in to change notification settings - Fork 2k
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
added _parent and context to data returned by #with in helpers #1840 #1952
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Seyed Mohammad Mahdi Hatami <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the right place for a test would be here:
handlebars.js/spec/builtins.js
Lines 136 to 184 in b4a54ad
describe('#with', function () { | |
it('with', function () { | |
expectTemplate('{{#with person}}{{first}} {{last}}{{/with}}') | |
.withInput({ | |
person: { | |
first: 'Alan', | |
last: 'Johnson', | |
}, | |
}) | |
.toCompileTo('Alan Johnson'); | |
}); | |
it('with with function argument', function () { | |
expectTemplate('{{#with person}}{{first}} {{last}}{{/with}}') | |
.withInput({ | |
person: function () { | |
return { | |
first: 'Alan', | |
last: 'Johnson', | |
}; | |
}, | |
}) | |
.toCompileTo('Alan Johnson'); | |
}); | |
it('with with else', function () { | |
expectTemplate( | |
'{{#with person}}Person is present{{else}}Person is not present{{/with}}' | |
).toCompileTo('Person is not present'); | |
}); | |
it('with provides block parameter', function () { | |
expectTemplate('{{#with person as |foo|}}{{foo.first}} {{last}}{{/with}}') | |
.withInput({ | |
person: { | |
first: 'Alan', | |
last: 'Johnson', | |
}, | |
}) | |
.toCompileTo('Alan Johnson'); | |
}); | |
it('works when data is disabled', function () { | |
expectTemplate('{{#with person as |foo|}}{{foo.first}} {{last}}{{/with}}') | |
.withInput({ person: { first: 'Alan', last: 'Johnson' } }) | |
.withCompileOptions({ data: false }) | |
.toCompileTo('Alan Johnson'); | |
}); | |
}); |
Tests can be run via npm install
and npm run test
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smmhatami Can you add a test for this? (See comment above on where to add it.)
This is a fix to solve Issue 1840. Resolves #1840. Added _parent and context to data returned by with in helpers just like each does to each iterated field.
I just couldn't find where and how should I add tests for this functionality, i would be glad if you help me with that.
thanks!