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

[RFC 445] Deprecate {{#with}} #19346

Merged
merged 1 commit into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@ember/-internals/glimmer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
@for Ember.Templates.helpers
@param {Object} options
@return {String} HTML string
@deprecated Use '{{#let}}' instead
@public
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,9 @@ moduleFor(
this.registerComponent('foo-bar', { template: 'hello' });

this.render(strip`
{{#with (component 'foo-bar') as |Other|}}
{{#let (component 'foo-bar') as |Other|}}
<Other />
{{/with}}
{{/let}}
`);

this.assertComponentElement(this.firstChild, { content: 'hello' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ moduleFor(

this.render(
strip`
{{#with (hash comp=(component "-looked-up" greeting=this.model.greeting)) as |my|}}
{{#let (hash comp=(component "-looked-up" greeting=this.model.greeting)) as |my|}}
{{#my.comp}}{{/my.comp}}
{{/with}}`,
{{/let}}`,
{
model: {
greeting: 'Hodi',
Expand Down Expand Up @@ -340,11 +340,11 @@ moduleFor(

this.render(
strip`
{{#with (component "-looked-up" greeting="Hola" name="Dolores" age=33) as |first|}}
{{#with (component first greeting="Hej" name="Sigmundur") as |second|}}
{{#let (component "-looked-up" greeting="Hola" name="Dolores" age=33) as |first|}}
{{#let (component first greeting="Hej" name="Sigmundur") as |second|}}
{{component second greeting=this.model.greeting}}
{{/with}}
{{/with}}`,
{{/let}}
{{/let}}`,
{
model: {
greeting: 'Hodi',
Expand Down Expand Up @@ -616,9 +616,9 @@ moduleFor(
});

this.render(strip`
{{#with (hash lookedup=(component "-looked-up")) as |object|}}
{{#let (hash lookedup=(component "-looked-up")) as |object|}}
{{object.lookedup}}
{{/with}}`);
{{/let}}`);

this.assertText(expectedText);

Expand All @@ -635,9 +635,9 @@ moduleFor(

this.render(
strip`
{{#with (hash lookedup=(component "-looked-up")) as |object|}}
{{#let (hash lookedup=(component "-looked-up")) as |object|}}
{{object.lookedup expectedText=this.model.expectedText}}
{{/with}}`,
{{/let}}`,
{
model: {
expectedText,
Expand Down Expand Up @@ -668,9 +668,9 @@ moduleFor(

this.render(
strip`
{{#with (hash lookedup=(component "-looked-up" expectedText=this.model.expectedText)) as |object|}}
{{#let (hash lookedup=(component "-looked-up" expectedText=this.model.expectedText)) as |object|}}
{{object.lookedup}}
{{/with}}`,
{{/let}}`,
{
model: {
expectedText,
Expand Down Expand Up @@ -705,9 +705,9 @@ moduleFor(

this.render(
strip`
{{#with (hash lookedup=(component "-looked-up")) as |object|}}
{{#let (hash lookedup=(component "-looked-up")) as |object|}}
{{object.lookedup this.model.expectedText "Hola"}}
{{/with}}`,
{{/let}}`,
{
model: {
expectedText,
Expand Down Expand Up @@ -748,9 +748,9 @@ moduleFor(

this.render(
strip`
{{#with (hash my-component=(component 'my-component' first)) as |c|}}
{{#let (hash my-component=(component 'my-component' first)) as |c|}}
{{c.my-component}}
{{/with}}`,
{{/let}}`,
{ first: 'first' }
);

Expand Down Expand Up @@ -946,9 +946,9 @@ moduleFor(

this.render(
strip`
{{#with (hash ctxCmp=(component "my-comp" isOpen=isOpen)) as |thing|}}
{{#let (hash ctxCmp=(component "my-comp" isOpen=isOpen)) as |thing|}}
{{#thing.ctxCmp}}This is a contextual component{{/thing.ctxCmp}}
{{/with}}
{{/let}}
`,
{
isOpen: true,
Expand Down Expand Up @@ -1010,9 +1010,9 @@ moduleFor(

this.render(
strip`
{{#with (hash ctxCmp=(component compName isOpen=isOpen)) as |thing|}}
{{#let (hash ctxCmp=(component compName isOpen=isOpen)) as |thing|}}
{{#thing.ctxCmp}}This is a contextual component{{/thing.ctxCmp}}
{{/with}}
{{/let}}
`,
{
compName: 'my-comp',
Expand Down Expand Up @@ -1088,9 +1088,9 @@ moduleFor(

this.render(
strip`
{{#with (hash ctxCmp=(component compName isOpen=isOpen)) as |thing|}}
{{#let (hash ctxCmp=(component compName isOpen=isOpen)) as |thing|}}
{{#thing.ctxCmp}}This is a contextual component{{/thing.ctxCmp}}
{{/with}}
{{/let}}
`,
{
compName: 'my-comp',
Expand Down Expand Up @@ -1198,7 +1198,7 @@ moduleFor(
});

this.render(
'{{#with (hash link=(component "my-link")) as |c|}}{{c.link params=allParams}}{{/with}}',
'{{#let (hash link=(component "my-link")) as |c|}}{{c.link params=allParams}}{{/let}}',
{
allParams: emberA(['a', 'b']),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ moduleFor(
class extends RenderingTestCase {
['@test returns an array']() {
this.render(strip`
{{#with (array "Sergio") as |people|}}
{{#let (array "Sergio") as |people|}}
{{#each people as |personName|}}
{{personName}}
{{/each}}
{{/with}}`);
{{/let}}`);

this.assertText('Sergio');

Expand All @@ -22,11 +22,11 @@ moduleFor(

['@test can have more than one value']() {
this.render(strip`
{{#with (array "Sergio" "Robert") as |people|}}
{{#let (array "Sergio" "Robert") as |people|}}
{{#each people as |personName|}}
{{personName}},
{{/each}}
{{/with}}`);
{{/let}}`);

this.assertText('Sergio,Robert,');

Expand All @@ -35,11 +35,11 @@ moduleFor(

['@test binds values when variables are used']() {
this.render(
strip`{{#with (array personOne) as |people|}}
strip`{{#let (array personOne) as |people|}}
{{#each people as |personName|}}
{{personName}}
{{/each}}
{{/with}}`,
{{/let}}`,
{
personOne: 'Tom',
}
Expand All @@ -58,11 +58,11 @@ moduleFor(

['@test binds multiple values when variables are used']() {
this.render(
strip`{{#with (array personOne personTwo) as |people|}}
strip`{{#let (array personOne personTwo) as |people|}}
{{#each people as |personName|}}
{{personName}},
{{/each}}
{{/with}}`,
{{/let}}`,
{
personOne: 'Tom',
personTwo: 'Yehuda',
Expand Down Expand Up @@ -91,14 +91,14 @@ moduleFor(

['@test array helpers can be nested']() {
this.render(
strip`{{#with (array (array personOne personTwo)) as |listOfPeople|}}
strip`{{#let (array (array personOne personTwo)) as |listOfPeople|}}
{{#each listOfPeople as |people|}}
List:
{{#each people as |personName|}}
{{personName}},
{{/each}}
{{/each}}
{{/with}}`,
{{/let}}`,
{
personOne: 'Tom',
personTwo: 'Yehuda',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ moduleFor(
this.assert.equal(editHandlerWasCalled, true, 'the event handler was called');
}

['@test it should work properly in a {{#with foo as |bar|}} block']() {
['@test it should work properly in a {{#let foo as |bar|}} block']() {
let editHandlerWasCalled = false;

let ExampleComponent = Component.extend({
Expand All @@ -792,7 +792,7 @@ moduleFor(
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template:
'{{#with something as |somethingElse|}}<a href="#" {{action "edit"}}>click me</a>{{/with}}',
'{{#let something as |somethingElse|}}<a href="#" {{action "edit"}}>click me</a>{{/let}}',
});

this.render('{{example-component}}');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ moduleFor(
'Helpers test: {{hash}}',
class extends RenderingTestCase {
['@test returns a hash with the right key-value']() {
this.render(`{{#with (hash name="Sergio") as |person|}}{{person.name}}{{/with}}`);
this.render(`{{#let (hash name="Sergio") as |person|}}{{person.name}}{{/let}}`);

this.assertText('Sergio');

Expand All @@ -19,7 +19,7 @@ moduleFor(

['@test can have more than one key-value']() {
this.render(
`{{#with (hash name="Sergio" lastName="Arbeo") as |person|}}{{person.name}} {{person.lastName}}{{/with}}`
`{{#let (hash name="Sergio" lastName="Arbeo") as |person|}}{{person.name}} {{person.lastName}}{{/let}}`
);

this.assertText('Sergio Arbeo');
Expand All @@ -31,7 +31,7 @@ moduleFor(

['@test binds values when variables are used']() {
this.render(
`{{#with (hash name=this.model.firstName lastName="Arbeo") as |person|}}{{person.name}} {{person.lastName}}{{/with}}`,
`{{#let (hash name=this.model.firstName lastName="Arbeo") as |person|}}{{person.name}} {{person.lastName}}{{/let}}`,
{
model: {
firstName: 'Marisa',
Expand All @@ -56,7 +56,7 @@ moduleFor(

['@test binds multiple values when variables are used']() {
this.render(
`{{#with (hash name=this.model.firstName lastName=this.model.lastName) as |person|}}{{person.name}} {{person.lastName}}{{/with}}`,
`{{#let (hash name=this.model.firstName lastName=this.model.lastName) as |person|}}{{person.name}} {{person.lastName}}{{/let}}`,
{
model: {
firstName: 'Marisa',
Expand Down Expand Up @@ -91,7 +91,7 @@ moduleFor(

['@test hash helpers can be nested']() {
this.render(
`{{#with (hash person=(hash name=this.model.firstName)) as |ctx|}}{{ctx.person.name}}{{/with}}`,
`{{#let (hash person=(hash name=this.model.firstName)) as |ctx|}}{{ctx.person.name}}{{/let}}`,
{
model: { firstName: 'Balint' },
}
Expand Down
Loading