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

Ensure templates with whitespace control are codemoded properly. #159

Merged
merged 2 commits into from
Oct 28, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"test": "qunit tests/**/*-test.js"
},
"dependencies": {
"@glimmer/syntax": "^0.42.2",
"@glimmer/syntax": "^0.43.0",
"async-promise-queue": "^1.0.5",
"colors": "^1.3.3",
"commander": "^3.0.0",
Expand Down
4 changes: 2 additions & 2 deletions tests/parse-result-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1003,12 +1003,12 @@ QUnit.module('ember-template-recast', function() {
QUnit.test(
'adding child to end of inverse preserves whitespace and whitespace control when program is also present',
function(assert) {
let template = `{{#foo-bar}}Goodbye{{~ else ~}}Hello{{/foo-bar}}`;
let template = `{{#foo-bar}}Goodbye\n {{~ else ~}} Hello{{/foo-bar}}`;

let ast = parse(template);
ast.body[0].inverse.body.push(builders.text(' world!'));

assert.equal(print(ast), '{{#foo-bar}}Goodbye{{~ else ~}}Hello world!{{/foo-bar}}');
assert.equal(print(ast), '{{#foo-bar}}Goodbye\n {{~ else ~}} Hello world!{{/foo-bar}}');
}
);

Expand Down
27 changes: 27 additions & 0 deletions tests/smoke-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,33 @@ QUnit.module('"real life" smoke tests', function() {
);
});

QUnit.test('`if` branch containing whitespace controls', function(assert) {
let template = `
{{#if foo~}}
{{foo}}
{{/if}}
`;

let expected = `
{{#if foo~}}
{{oof}}
{{/if}}
`;

let { code } = transform(template, () => {
return {
MustacheStatement(node) {
node.path.original = node.path.original
.split('')
.reverse()
.join('');
},
};
});

assert.equal(code, expected);
});

QUnit.test('collapsing lines (full line replacment)', function(assert) {
let template = stripIndent`
here
Expand Down
32 changes: 16 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@
exec-sh "^0.3.2"
minimist "^1.2.0"

"@glimmer/interfaces@^0.42.2":
version "0.42.2"
resolved "https://registry.yarnpkg.com/@glimmer/interfaces/-/interfaces-0.42.2.tgz#9cf8d6f8f5eee6bfcfa36919ca68ae716e1f78db"
integrity sha512-7LOuQd02cxxNNHChzdHMAU8/qOeQvTro141CU5tXITP7z6aOv2D2gkFdau97lLQiVxezGrh8J7h8GCuF7TEqtg==

"@glimmer/syntax@^0.42.2":
version "0.42.2"
resolved "https://registry.yarnpkg.com/@glimmer/syntax/-/syntax-0.42.2.tgz#89bb3cb787285b84665dc0d8907d94b008e5be9a"
integrity sha512-SR26SmF/Mb5o2cc4eLHpOyoX5kwwXP4KRhq4fbWfrvan74xVWA38PLspPCzwGhyVH/JsE7tUEPMjSo2DcJge/Q==
dependencies:
"@glimmer/interfaces" "^0.42.2"
"@glimmer/util" "^0.42.2"
"@glimmer/interfaces@^0.43.0":
version "0.43.0"
resolved "https://registry.yarnpkg.com/@glimmer/interfaces/-/interfaces-0.43.0.tgz#a7a38c2476f87d68d6dc894840df17bc8b92de33"
integrity sha512-rWu6WHVo6tuFFOKOSJWAWsFfXZgkdnKDnvhl3tAb20njW/0uBZ2nx7GZ3lImvBeG0HoxyzYA7pD299ps03TemA==

"@glimmer/syntax@^0.43.0":
version "0.43.0"
resolved "https://registry.yarnpkg.com/@glimmer/syntax/-/syntax-0.43.0.tgz#d6e30c857c575eeac25b3f7ffab2cfee43685726"
integrity sha512-qJqzcbF9lgdLE5A1rCwTs0CLnblNK95Y6MMLNsvJEJA7j1Gx50ySoUZ5HTk86Z5auhDgvInhuufyGtdojSIMSg==
dependencies:
"@glimmer/interfaces" "^0.43.0"
"@glimmer/util" "^0.43.0"
handlebars "^4.0.13"
simple-html-tokenizer "^0.5.8"

"@glimmer/util@^0.42.2":
version "0.42.2"
resolved "https://registry.yarnpkg.com/@glimmer/util/-/util-0.42.2.tgz#9ca1631e42766ea6059f4b49d0bdfb6095aad2c4"
integrity sha512-Heck0baFSaWDanCYtmOcLeaz7v+rSqI8ovS7twrp2/FWEteb3Ze5sWQ2BEuSAG23L/k/lzVwYM/MY7ZugxBpaA==
"@glimmer/util@^0.43.0":
version "0.43.0"
resolved "https://registry.yarnpkg.com/@glimmer/util/-/util-0.43.0.tgz#dd28cd1a233c25427032437b9050c6fa6d098e2c"
integrity sha512-RtjHU8/rhysOugu+Q0j6dQ3G67J4h45tQgKPEwVPxu8P+hqijqnz/lBLxTdVg/1zKmlqUkyngTr8H4Jpg2yF/g==

"@iarna/toml@2.2.3":
version "2.2.3"
Expand Down