Skip to content

Commit 974fdaa

Browse files
authored
Merge pull request #1574 from glimmerjs/rm-with
[CLEANUP] Drop support for `{{#with}}` keyword
2 parents ed002cc + 27197c2 commit 974fdaa

File tree

14 files changed

+56
-188
lines changed

14 files changed

+56
-188
lines changed

packages/@glimmer-workspace/integration-tests/lib/suites/components.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ export class GlimmerishComponents extends RenderTest {
268268
})
269269
'invoking dynamic component (local) via angle brackets'() {
270270
this.registerComponent('Glimmer', 'Foo', 'hello world!');
271-
this.render(`{{#with (component 'Foo') as |Other|}}<Other />{{/with}}`);
271+
this.render(`{{#let (component 'Foo') as |Other|}}<Other />{{/let}}`);
272272

273273
this.assertHTML(`hello world!`);
274274
this.assertStableRerender();
@@ -280,7 +280,7 @@ export class GlimmerishComponents extends RenderTest {
280280
'invoking dynamic component (local path) via angle brackets'() {
281281
this.registerHelper('hash', (_positional, named) => named);
282282
this.registerComponent('Glimmer', 'Foo', 'hello world!');
283-
this.render(`{{#with (hash Foo=(component 'Foo')) as |Other|}}<Other.Foo />{{/with}}`);
283+
this.render(`{{#let (hash Foo=(component 'Foo')) as |Other|}}<Other.Foo />{{/let}}`);
284284

285285
this.assertHTML(`hello world!`);
286286
this.assertStableRerender();
@@ -291,7 +291,7 @@ export class GlimmerishComponents extends RenderTest {
291291
})
292292
'invoking dynamic component (local) via angle brackets (ill-advised "htmlish element name" but supported)'() {
293293
this.registerComponent('Glimmer', 'Foo', 'hello world!');
294-
this.render(`{{#with (component 'Foo') as |div|}}<div />{{/with}}`);
294+
this.render(`{{#let (component 'Foo') as |div|}}<div />{{/let}}`);
295295

296296
this.assertHTML(`hello world!`);
297297
this.assertStableRerender();
@@ -302,7 +302,7 @@ export class GlimmerishComponents extends RenderTest {
302302
})
303303
'invoking dynamic component (local) via angle brackets supports attributes'() {
304304
this.registerComponent('Glimmer', 'Foo', '<div ...attributes>hello world!</div>');
305-
this.render(`{{#with (component 'Foo') as |Other|}}<Other data-test="foo" />{{/with}}`);
305+
this.render(`{{#let (component 'Foo') as |Other|}}<Other data-test="foo" />{{/let}}`);
306306

307307
this.assertHTML(`<div data-test="foo">hello world!</div>`);
308308
this.assertStableRerender();
@@ -313,7 +313,7 @@ export class GlimmerishComponents extends RenderTest {
313313
})
314314
'invoking dynamic component (local) via angle brackets supports args'() {
315315
this.registerComponent('Glimmer', 'Foo', 'hello {{@name}}!');
316-
this.render(`{{#with (component 'Foo') as |Other|}}<Other @name="world" />{{/with}}`);
316+
this.render(`{{#let (component 'Foo') as |Other|}}<Other @name="world" />{{/let}}`);
317317

318318
this.assertHTML(`hello world!`);
319319
this.assertStableRerender();
@@ -324,7 +324,7 @@ export class GlimmerishComponents extends RenderTest {
324324
})
325325
'invoking dynamic component (local) via angle brackets supports passing a block'() {
326326
this.registerComponent('Glimmer', 'Foo', 'hello {{yield}}!');
327-
this.render(`{{#with (component 'Foo') as |Other|}}<Other>world</Other>{{/with}}`);
327+
this.render(`{{#let (component 'Foo') as |Other|}}<Other>world</Other>{{/let}}`);
328328

329329
this.assertHTML(`hello world!`);
330330
this.assertStableRerender();
@@ -351,7 +351,7 @@ export class GlimmerishComponents extends RenderTest {
351351
Foo
352352
);
353353
this.render(
354-
`{{#with (component 'Foo') as |Other|}}<Other @staticNamedArg="static" data-test1={{this.outer}} data-test2="static" @dynamicNamedArg={{this.outer}}>template</Other>{{/with}}`,
354+
`{{#let (component 'Foo') as |Other|}}<Other @staticNamedArg="static" data-test1={{this.outer}} data-test2="static" @dynamicNamedArg={{this.outer}}>template</Other>{{/let}}`,
355355
{ outer: 'outer' }
356356
);
357357

packages/@glimmer-workspace/integration-tests/lib/suites/debugger.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class DebuggerSuite extends RenderTest {
7575
});
7676

7777
this.render(
78-
'{{#with this.foo as |bar|}}{{#if this.a.b}}true{{debugger}}{{else}}false{{debugger}}{{/if}}{{/with}}',
78+
'{{#let this.foo as |bar|}}{{#if this.a.b}}true{{debugger}}{{else}}false{{debugger}}{{/if}}{{/let}}',
7979
expectedContext
8080
);
8181
this.assert.strictEqual(callbackExecuted, 1);

packages/@glimmer-workspace/integration-tests/lib/suites/scope.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ export class ScopeSuite extends RenderTest {
99
'correct scope - conflicting local names'() {
1010
this.render({
1111
layout: stripTight`
12-
{{#with @a as |item|}}{{@a}}: {{item}},
13-
{{#with @b as |item|}} {{@b}}: {{item}},
14-
{{#with @c as |item|}} {{@c}}: {{item}}{{/with}}
15-
{{/with}}
16-
{{/with}}`,
12+
{{#let @a as |item|}}{{@a}}: {{item}},
13+
{{#let @b as |item|}} {{@b}}: {{item}},
14+
{{#let @c as |item|}} {{@c}}: {{item}}{{/let}}
15+
{{/let}}
16+
{{/let}}`,
1717
args: { a: '"A"', b: '"B"', c: '"C"' },
1818
});
1919

@@ -25,7 +25,7 @@ export class ScopeSuite extends RenderTest {
2525
'correct scope - conflicting block param and attr names'() {
2626
this.render({
2727
layout:
28-
'Outer: {{@conflict}} {{#with @item as |conflict|}}Inner: {{@conflict}} Block: {{conflict}}{{/with}}',
28+
'Outer: {{@conflict}} {{#let @item as |conflict|}}Inner: {{@conflict}} Block: {{conflict}}{{/let}}',
2929
args: { item: '"from block"', conflict: '"from attr"' },
3030
});
3131

packages/@glimmer-workspace/integration-tests/test/ember-component-test.ts

+18-18
Original file line numberDiff line numberDiff line change
@@ -372,14 +372,14 @@ class CurlyScopeTest extends CurlyTest {
372372
stripTight`
373373
<div>
374374
[Outside: {{this.zomg}}]
375-
{{#with this.zomg as |lol|}}
375+
{{#let this.zomg as |lol|}}
376376
[Inside: {{this.zomg}}]
377377
[Inside: {{lol}}]
378378
<FooBar @foo={{this.zomg}}>
379379
[Block: {{this.zomg}}]
380380
[Block: {{lol}}]
381381
</FooBar>
382-
{{/with}}
382+
{{/let}}
383383
</div>`,
384384
{ zomg: 'zomg' }
385385
);
@@ -419,14 +419,14 @@ class CurlyScopeTest extends CurlyTest {
419419
stripTight`
420420
<div>
421421
[Outside: {{this.zomg}}]
422-
{{#with this.zomg as |lol|}}
422+
{{#let this.zomg as |lol|}}
423423
[Inside: {{this.zomg}}]
424424
[Inside: {{lol}}]
425425
{{#foo-bar foo=this.zomg}}
426426
[Block: {{this.zomg}}]
427427
[Block: {{lol}}]
428428
{{/foo-bar}}
429-
{{/with}}
429+
{{/let}}
430430
</div>`,
431431
{ zomg: 'zomg' }
432432
);
@@ -991,9 +991,9 @@ class CurlyClosureComponentsTest extends CurlyTest {
991991

992992
this.render(
993993
stripTight`
994-
{{#with (hash comp=(component 'foo-bar')) as |my|}}
994+
{{#let (hash comp=(component 'foo-bar')) as |my|}}
995995
{{#component my.comp arg1="World!"}}Test1{{/component}} Test2
996-
{{/with}}
996+
{{/let}}
997997
`
998998
);
999999

@@ -1007,9 +1007,9 @@ class CurlyClosureComponentsTest extends CurlyTest {
10071007

10081008
this.render(
10091009
stripTight`
1010-
{{#with (hash comp=(component 'foo-bar')) as |my|}}
1010+
{{#let (hash comp=(component 'foo-bar')) as |my|}}
10111011
{{#component my.comp}}World!{{/component}} Test
1012-
{{/with}}
1012+
{{/let}}
10131013
`
10141014
);
10151015

@@ -1023,9 +1023,9 @@ class CurlyClosureComponentsTest extends CurlyTest {
10231023

10241024
this.render(
10251025
stripTight`
1026-
{{#with (hash comp=(component 'foo-bar')) as |my|}}
1026+
{{#let (hash comp=(component 'foo-bar')) as |my|}}
10271027
{{component my.comp arg1="World!"}} Test
1028-
{{/with}}
1028+
{{/let}}
10291029
`
10301030
);
10311031

@@ -1039,9 +1039,9 @@ class CurlyClosureComponentsTest extends CurlyTest {
10391039

10401040
this.render(
10411041
stripTight`
1042-
{{#with (hash comp=(component 'foo-bar')) as |my|}}
1042+
{{#let (hash comp=(component 'foo-bar')) as |my|}}
10431043
{{component my.comp}} World!
1044-
{{/with}}
1044+
{{/let}}
10451045
`
10461046
);
10471047

@@ -1131,9 +1131,9 @@ class CurlyClosureComponentsTest extends CurlyTest {
11311131

11321132
this.render(
11331133
stripTight`
1134-
{{#with (hash comp=(component 'foo-bar')) as |my|}}
1134+
{{#let (hash comp=(component 'foo-bar')) as |my|}}
11351135
{{my.comp}} World!
1136-
{{/with}}
1136+
{{/let}}
11371137
`
11381138
);
11391139

@@ -1190,11 +1190,11 @@ class CurlyClosureComponentsTest extends CurlyTest {
11901190

11911191
this.render(
11921192
stripTight`
1193-
{{#with (component "foo-bar" "outer 1" "outer 2" a="outer a" b="outer b" c="outer c" e="outer e") as |outer|}}
1194-
{{#with (component outer "inner 1" a="inner a" d="inner d" e="inner e") as |inner|}}
1193+
{{#let (component "foo-bar" "outer 1" "outer 2" a="outer a" b="outer b" c="outer c" e="outer e") as |outer|}}
1194+
{{#let (component outer "inner 1" a="inner a" d="inner d" e="inner e") as |inner|}}
11951195
{{#component inner "invocation 1" "invocation 2" a="invocation a" b="invocation b"}}---{{/component}}
1196-
{{/with}}
1197-
{{/with}}
1196+
{{/let}}
1197+
{{/let}}
11981198
`
11991199
);
12001200

packages/@glimmer-workspace/integration-tests/test/helpers/array-test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ class ArrayTest extends RenderTest {
66
@test
77
'returns an array'() {
88
this.render(strip`
9-
{{#with (array "Sergio") as |people|}}
9+
{{#let (array "Sergio") as |people|}}
1010
{{#each people as |personName|}}
1111
{{personName}}
1212
{{/each}}
13-
{{/with}}`);
13+
{{/let}}`);
1414

1515
this.assertHTML('Sergio');
1616

@@ -20,11 +20,11 @@ class ArrayTest extends RenderTest {
2020
@test
2121
'can have more than one value'() {
2222
this.render(strip`
23-
{{#with (array "Sergio" "Robert") as |people|}}
23+
{{#let (array "Sergio" "Robert") as |people|}}
2424
{{#each people as |personName|}}
2525
{{personName}},
2626
{{/each}}
27-
{{/with}}`);
27+
{{/let}}`);
2828

2929
this.assertHTML('Sergio,Robert,');
3030

@@ -34,11 +34,11 @@ class ArrayTest extends RenderTest {
3434
@test
3535
'binds values when variables are used'() {
3636
this.render(
37-
strip`{{#with (array this.personOne) as |people|}}
37+
strip`{{#let (array this.personOne) as |people|}}
3838
{{#each people as |personName|}}
3939
{{personName}}
4040
{{/each}}
41-
{{/with}}`,
41+
{{/let}}`,
4242
{
4343
personOne: 'Tom',
4444
}
@@ -58,11 +58,11 @@ class ArrayTest extends RenderTest {
5858
@test
5959
'binds multiple values when variables are used'() {
6060
this.render(
61-
strip`{{#with (array this.personOne this.personTwo) as |people|}}
61+
strip`{{#let (array this.personOne this.personTwo) as |people|}}
6262
{{#each people as |personName|}}
6363
{{personName}},
6464
{{/each}}
65-
{{/with}}`,
65+
{{/let}}`,
6666
{
6767
personOne: 'Tom',
6868
personTwo: 'Yehuda',

packages/@glimmer-workspace/integration-tests/test/updating-test.ts

+12-23
Original file line numberDiff line numberDiff line change
@@ -560,17 +560,6 @@ class UpdatingTest extends RenderTest {
560560
this.testStatefulHelper(assert, options);
561561
}
562562

563-
@test
564-
'helpers passed as arguments to {{#with}} are not torn down when switching between blocks'() {
565-
let options = {
566-
template: '{{#with (stateful-foo) as |unused|}}Yes{{/with}}',
567-
truthyValue: {},
568-
falsyValue: null,
569-
};
570-
571-
this.testStatefulHelper(assert, options);
572-
}
573-
574563
@test
575564
'helpers passed as arguments to {{#each}} are not torn down when switching between blocks'() {
576565
let options = {
@@ -900,7 +889,7 @@ class UpdatingTest extends RenderTest {
900889

901890
const person = { name: new Name('Godfrey', 'Chan') };
902891

903-
this.render('<div>{{#with this.person.name.first as |f|}}{{f}}{{/with}}</div>', {
892+
this.render('<div>{{#let this.person.name.first as |f|}}{{f}}{{/let}}</div>', {
904893
person,
905894
});
906895

@@ -943,7 +932,7 @@ class UpdatingTest extends RenderTest {
943932
944933
-----
945934
946-
{{#with this.value as |foo|}}
935+
{{#let this.value as |foo|}}
947936
foo: "{{foo}}";
948937
bar: "{{bar}}";
949938
value: "{{this.value}}";
@@ -953,26 +942,26 @@ class UpdatingTest extends RenderTest {
953942
954943
-----
955944
956-
{{#with foo as |bar|}}
945+
{{#let foo as |bar|}}
957946
foo: "{{foo}}";
958947
bar: "{{bar}}";
959948
value: "{{this.value}}";
960949
echo foo: "{{echo foo}}";
961950
echo bar: "{{echo bar}}";
962951
echo value: "{{echo this.value}}";
963-
{{/with}}
964-
{{/with}}
952+
{{/let}}
953+
{{/let}}
965954
966955
-----
967956
968-
{{#with this.value as |bar|}}
957+
{{#let this.value as |bar|}}
969958
foo: "{{foo}}";
970959
bar: "{{bar}}";
971960
value: "{{this.value}}";
972961
echo foo: "{{echo this.foo}}";
973962
echo bar: "{{echo bar}}";
974963
echo value: "{{echo this.value}}";
975-
{{/with}}
964+
{{/let}}
976965
</div>
977966
`;
978967

@@ -1108,7 +1097,7 @@ class UpdatingTest extends RenderTest {
11081097
@test
11091098
'block arguments (ensure balanced push/pop)'() {
11101099
let person = { name: { first: 'Godfrey', last: 'Chan' } };
1111-
this.render('<div>{{#with this.person.name.first as |f|}}{{f}}{{/with}}{{this.f}}</div>', {
1100+
this.render('<div>{{#let this.person.name.first as |f|}}{{f}}{{/let}}{{this.f}}</div>', {
11121101
person,
11131102
f: 'Outer',
11141103
});
@@ -1128,9 +1117,9 @@ class UpdatingTest extends RenderTest {
11281117
this.render(
11291118
stripTight`
11301119
<div>
1131-
[{{#with this.person as |name|}}{{this.name}}{{/with}}]
1132-
[{{#with this.person as |name|}}{{#with this.name as |test|}}{{test}}{{/with}}{{/with}}]
1133-
[{{#with this.person as |name|}}{{#with (noop this.name) as |test|}}{{test}}{{/with}}{{/with}}]
1120+
[{{#let this.person as |name|}}{{this.name}}{{/let}}]
1121+
[{{#let this.person as |name|}}{{#let this.name as |test|}}{{test}}{{/let}}{{/let}}]
1122+
[{{#let this.person as |name|}}{{#let (noop this.name) as |test|}}{{test}}{{/let}}{{/let}}]
11341123
</div>
11351124
`,
11361125
{ person: 'Yehuda', name: 'Godfrey' }
@@ -1148,7 +1137,7 @@ class UpdatingTest extends RenderTest {
11481137

11491138
@test
11501139
'The with helper should consider an empty array truthy'() {
1151-
this.render('<div>{{#with this.condition as |c|}}{{c.length}}{{/with}}</div>', {
1140+
this.render('<div>{{#let this.condition as |c|}}{{c.length}}{{/let}}</div>', {
11521141
condition: [],
11531142
});
11541143

packages/@glimmer/compiler/lib/builder/builder.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ function buildKeyword(
341341
: null;
342342

343343
switch (name) {
344-
case 'with':
345-
return [Op.With, expect(params, 'with requires params')[0], block, inverse];
344+
case 'let':
345+
return [Op.Let, expect(params, 'let requires params'), block];
346346
case 'if':
347347
return [Op.If, expect(params, 'if requires params')[0], block, inverse];
348348
case 'each': {

0 commit comments

Comments
 (0)