diff --git a/generate_golden.js b/generate_golden.js new file mode 100644 index 00000000..35521b69 --- /dev/null +++ b/generate_golden.js @@ -0,0 +1,127 @@ +import Handlebars from './lib/index.js'; +import fs from 'fs'; + +// Read the basic.js test file and extract test cases +// For now, manually define a set of representative test cases +const tests = []; + +function T(template, input, expected, opts) { + tests.push({ + template, + input: input ?? {}, + expected, + compileOpts: opts?.compile ?? {}, + runtimeOpts: opts?.runtime ?? {}, + }); +} + +// ============ basic.js equivalents ============ +const g = (t, i, e, co, ro) => T(t, i, e, { compile: co, runtime: ro }); + +g('{{foo}}', { foo: 'foo' }, 'foo'); +g('\\{{foo}}', { foo: 'food' }, '{{foo}}'); +g('content \\{{foo}}', { foo: 'food' }, 'content {{foo}}'); +g('\\\\{{foo}}', { foo: 'food' }, '\\food'); +g('\\\\ {{foo}}', { foo: 'food' }, '\\\\ food'); +g( + 'Goodbye\n{{cruel}}\n{{world}}!', + { cruel: 'cruel', world: 'world' }, + 'Goodbye\ncruel\nworld!' +); +g('{{.}}{{length}}', 'bye', 'bye3'); +g('Goodbye\n{{cruel}}\n{{world.bar}}!', undefined, 'Goodbye\n\n!'); +g( + '{{! Goodbye}}Goodbye\n{{cruel}}\n{{world}}!', + { cruel: 'cruel', world: 'world' }, + 'Goodbye\ncruel\nworld!' +); +g(' {{~! comment ~}} blah', {}, 'blah'); +g(' {{~!-- long-comment --~}} blah', {}, 'blah'); +g(' {{! comment ~}} blah', {}, ' blah'); +g(' {{~! comment}} blah', {}, ' blah'); +g('{{#if foo}}foo{{/if}}', { foo: true }, 'foo'); +g('{{#if foo}}foo{{else}}bar{{/if}}', { foo: false }, 'bar'); +g('{{#unless foo}}bar{{/unless}}', { foo: false }, 'bar'); +g('{{#with foo}}{{bar}}{{/with}}', { foo: { bar: 'baz' } }, 'baz'); +g('{{#each items}}{{this}}{{/each}}', { items: ['a', 'b', 'c'] }, 'abc'); +g('{{#each items}}{{@index}}{{/each}}', { items: ['a', 'b'] }, '01'); +g('{{foo}}', { foo: '&' }, '&'); +g('{{{foo}}}', { foo: '' }, ''); +g('{{foo.bar}}', { foo: { bar: 'baz' } }, 'baz'); +g('{{foo/bar}}', { foo: { bar: 'baz' } }, 'baz'); +g('{{../foo}}', {}, ''); // depth at root = empty +g('{{{foo}}}', { foo: '&' }, '&'); + +// ============ blocks.js equivalents ============ +g( + '{{#list people}}{{firstName}} {{lastName}}\n{{/list}}', + { + people: [ + { firstName: 'Yehuda', lastName: 'Katz' }, + { firstName: 'Carl', lastName: 'Lerche' }, + ], + }, + 'Yehuda Katz\nCarl Lerche\n' +); +g( + '{{#list people}}{{../prefix}} {{firstName}}\n{{/list}}', + { people: [{ firstName: 'Yehuda' }, { firstName: 'Carl' }], prefix: 'Mr' }, + 'Mr Yehuda\nMr Carl\n' +); +g( + '{{#each people as |person|}}{{person}}\n{{/each}}', + { people: ['Yehuda', 'Carl'] }, + 'Yehuda\nCarl\n' +); + +// ============ builtins.js equivalents ============ +g( + '{{#if goodbye}}GOODBYE {{/if}}cruel {{world}}!', + { goodbye: true, world: 'world' }, + 'GOODBYE cruel world!' +); +g( + '{{#if goodbye}}GOODBYE {{/if}}cruel {{world}}!', + { goodbye: false, world: 'world' }, + 'cruel world!' +); +g('{{lookup foo "bar"}}', { foo: { bar: 'val' } }, 'val'); +g( + '{{#each items as |value key|}}{{key}}:{{value}},{{/each}}', + { items: { a: 1, b: 2 } }, + 'a:1,b:2,' +); + +// Write output +const results = tests.map((t, i) => { + let result, + error = null; + try { + const env = Handlebars.create(); + const compiled = env.compile(t.template, t.compileOpts); + result = compiled(t.input, t.runtimeOpts); + } catch (e) { + error = e.message; + result = null; + } + return { + i, + template: t.template, + input: JSON.stringify(t.input), + expected: t.expected, + result, + error, + }; +}); + +fs.writeFileSync('/tmp/golden_results.json', JSON.stringify(results, null, 2)); +console.log(`Generated ${results.length} golden results`); +const failures = results.filter((r) => r.result !== r.expected); +if (failures.length) { + console.log(`\nFAILURES (${failures.length}):`); + failures.forEach((f) => + console.log( + ` [${f.i}] "${f.template}" expected="${f.expected}" got="${f.result}" error="${f.error}"` + ) + ); +} diff --git a/package-lock.json b/package-lock.json index 6f7dcd8b..d6595769 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2010,18 +2010,6 @@ "url": "https://github.com/sponsors/nzakas" } }, - "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.13", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", - "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.5.0", - "@jridgewell/trace-mapping": "^0.3.24" - } - }, "node_modules/@jridgewell/resolve-uri": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", @@ -2032,18 +2020,6 @@ "node": ">=6.0.0" } }, - "node_modules/@jridgewell/source-map": { - "version": "0.3.11", - "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.11.tgz", - "integrity": "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.25" - } - }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", @@ -3351,7 +3327,6 @@ "integrity": "sha512-kT6yYo8xjKoDfM7iB8N9AmN9DJIlrs7UmQDbpTu1N4zaZocN1/t2fIAWOKjr5+3eJlZQR2twKZhDVHNLbLPjOw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@module-federation/runtime-tools": "0.22.0", "@rspack/binding": "1.7.8", @@ -5154,7 +5129,6 @@ "integrity": "sha512-gVQqh7paBz3gC+ZdcCmNSWJMk70IUjDeVqi+5m5vYpEHsIwRgw3Y545jljtajhkekIpIp5Gg8oK7bctgY0E2Ng==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@vitest/mocker": "4.0.18", "@vitest/utils": "4.0.18", @@ -5508,7 +5482,6 @@ "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -5948,7 +5921,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -5963,13 +5935,6 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, - "node_modules/buffer-from": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", - "dev": true, - "optional": true - }, "node_modules/bundle-name": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.0.tgz", @@ -6211,13 +6176,6 @@ "dev": true, "license": "MIT" }, - "node_modules/commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true, - "optional": true - }, "node_modules/compressible": { "version": "2.0.18", "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.18.tgz", @@ -6883,7 +6841,6 @@ "integrity": "sha512-COV33RzXZkqhG9P2rZCFl9ZmJ7WL+gQSCRzE7RhkbclbQPtLAWReL7ysA0Sh4c8Im2U9ynybdR56PV0XcKvqaQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.2", @@ -9097,8 +9054,7 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", "dev": true, - "license": "0BSD", - "peer": true + "license": "0BSD" }, "node_modules/merge-descriptors": { "version": "1.0.3", @@ -10192,7 +10148,6 @@ "integrity": "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -10913,49 +10868,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/terser": { - "version": "5.46.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.46.0.tgz", - "integrity": "sha512-jTwoImyr/QbOWFFso3YoU3ik0jBBDJ6JTOQiy/J2YxVJdZCc+5u7skhNwiOR3FQIygFqVUPHl7qbbxtjW2K3Qg==", - "dev": true, - "license": "BSD-2-Clause", - "optional": true, - "dependencies": { - "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.15.0", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - }, - "bin": { - "terser": "bin/terser" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/terser/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "license": "BSD-3-Clause", - "optional": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/terser/node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, "node_modules/thunky": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz", @@ -11024,7 +10936,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -11167,7 +11078,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -11305,7 +11215,6 @@ "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", @@ -11399,7 +11308,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -11413,7 +11321,6 @@ "integrity": "sha512-hOQuK7h0FGKgBAas7v0mSAsnvrIgAvWmRFjmzpJ7SwFHH3g1k2u37JtYwOwmEKhK6ZO3v9ggDBBm0La1LCK4uQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@vitest/expect": "4.0.18", "@vitest/mocker": "4.0.18", @@ -13290,34 +13197,12 @@ "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", "dev": true }, - "@jridgewell/gen-mapping": { - "version": "0.3.13", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", - "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", - "dev": true, - "optional": true, - "requires": { - "@jridgewell/sourcemap-codec": "^1.5.0", - "@jridgewell/trace-mapping": "^0.3.24" - } - }, "@jridgewell/resolve-uri": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", "dev": true }, - "@jridgewell/source-map": { - "version": "0.3.11", - "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.11.tgz", - "integrity": "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==", - "dev": true, - "optional": true, - "requires": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.25" - } - }, "@jridgewell/sourcemap-codec": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", @@ -13975,7 +13860,6 @@ "resolved": "https://registry.npmjs.org/@rspack/core/-/core-1.7.8.tgz", "integrity": "sha512-kT6yYo8xjKoDfM7iB8N9AmN9DJIlrs7UmQDbpTu1N4zaZocN1/t2fIAWOKjr5+3eJlZQR2twKZhDVHNLbLPjOw==", "dev": true, - "peer": true, "requires": { "@module-federation/runtime-tools": "0.22.0", "@rspack/binding": "1.7.8", @@ -15442,7 +15326,6 @@ "resolved": "https://registry.npmjs.org/@vitest/browser/-/browser-4.0.18.tgz", "integrity": "sha512-gVQqh7paBz3gC+ZdcCmNSWJMk70IUjDeVqi+5m5vYpEHsIwRgw3Y545jljtajhkekIpIp5Gg8oK7bctgY0E2Ng==", "dev": true, - "peer": true, "requires": { "@vitest/mocker": "4.0.18", "@vitest/utils": "4.0.18", @@ -15657,8 +15540,7 @@ "version": "8.16.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz", "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", - "dev": true, - "peer": true + "dev": true }, "acorn-jsx": { "version": "5.3.2", @@ -15962,7 +15844,6 @@ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.1.tgz", "integrity": "sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA==", "dev": true, - "peer": true, "requires": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -15971,13 +15852,6 @@ "update-browserslist-db": "^1.2.0" } }, - "buffer-from": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", - "dev": true, - "optional": true - }, "bundle-name": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.0.tgz", @@ -16145,13 +16019,6 @@ "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", "dev": true }, - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true, - "optional": true - }, "compressible": { "version": "2.0.18", "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.18.tgz", @@ -16669,7 +16536,6 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.0.3.tgz", "integrity": "sha512-COV33RzXZkqhG9P2rZCFl9ZmJ7WL+gQSCRzE7RhkbclbQPtLAWReL7ysA0Sh4c8Im2U9ynybdR56PV0XcKvqaQ==", "dev": true, - "peer": true, "requires": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.2", @@ -18088,8 +17954,7 @@ "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "dev": true, - "peer": true + "dev": true } } }, @@ -18817,7 +18682,6 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz", "integrity": "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==", "dev": true, - "peer": true, "requires": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -19356,39 +19220,6 @@ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true }, - "terser": { - "version": "5.46.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.46.0.tgz", - "integrity": "sha512-jTwoImyr/QbOWFFso3YoU3ik0jBBDJ6JTOQiy/J2YxVJdZCc+5u7skhNwiOR3FQIygFqVUPHl7qbbxtjW2K3Qg==", - "dev": true, - "optional": true, - "requires": { - "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.15.0", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "optional": true - }, - "source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, - "optional": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - } - } - }, "thunky": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz", @@ -19428,8 +19259,7 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", - "dev": true, - "peer": true + "dev": true } } }, @@ -19516,8 +19346,7 @@ "version": "5.9.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", - "dev": true, - "peer": true + "dev": true }, "uglify-js": { "version": "3.19.3", @@ -19601,7 +19430,6 @@ "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.1.tgz", "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", "dev": true, - "peer": true, "requires": { "esbuild": "^0.27.0", "fdir": "^6.5.0", @@ -19623,8 +19451,7 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", - "dev": true, - "peer": true + "dev": true } } }, @@ -19633,7 +19460,6 @@ "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.0.18.tgz", "integrity": "sha512-hOQuK7h0FGKgBAas7v0mSAsnvrIgAvWmRFjmzpJ7SwFHH3g1k2u37JtYwOwmEKhK6ZO3v9ggDBBm0La1LCK4uQ==", "dev": true, - "peer": true, "requires": { "@vitest/expect": "4.0.18", "@vitest/mocker": "4.0.18", diff --git a/test_fixtures/0.ast.json b/test_fixtures/0.ast.json new file mode 100644 index 00000000..39db4c23 --- /dev/null +++ b/test_fixtures/0.ast.json @@ -0,0 +1,52 @@ +{ + "type": "Program", + "body": [ + { + "type": "ContentStatement", + "original": "Hello ", + "value": "Hello ", + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 6 } + } + }, + { + "type": "MustacheStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "name", + "tail": [], + "parts": ["name"], + "original": "name", + "loc": { + "start": { "line": 1, "column": 8 }, + "end": { "line": 1, "column": 12 } + } + }, + "params": [], + "escaped": true, + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 6 }, + "end": { "line": 1, "column": 14 } + } + }, + { + "type": "ContentStatement", + "original": "!", + "value": "!", + "loc": { + "start": { "line": 1, "column": 14 }, + "end": { "line": 1, "column": 15 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 15 } + } +} diff --git a/test_fixtures/0.hbs b/test_fixtures/0.hbs new file mode 100644 index 00000000..2f082306 --- /dev/null +++ b/test_fixtures/0.hbs @@ -0,0 +1 @@ +Hello {{name}}! \ No newline at end of file diff --git a/test_fixtures/1.ast.json b/test_fixtures/1.ast.json new file mode 100644 index 00000000..410743e2 --- /dev/null +++ b/test_fixtures/1.ast.json @@ -0,0 +1,88 @@ +{ + "type": "Program", + "body": [ + { + "type": "BlockStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "if", + "tail": [], + "parts": ["if"], + "original": "if", + "loc": { + "start": { "line": 1, "column": 3 }, + "end": { "line": 1, "column": 5 } + } + }, + "params": [ + { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "active", + "tail": [], + "parts": ["active"], + "original": "active", + "loc": { + "start": { "line": 1, "column": 6 }, + "end": { "line": 1, "column": 12 } + } + } + ], + "program": { + "type": "Program", + "body": [ + { + "type": "ContentStatement", + "original": "yes", + "value": "yes", + "loc": { + "start": { "line": 1, "column": 14 }, + "end": { "line": 1, "column": 17 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 14 }, + "end": { "line": 1, "column": 17 } + } + }, + "inverse": { + "type": "Program", + "body": [ + { + "type": "ContentStatement", + "original": "no", + "value": "no", + "loc": { + "start": { "line": 1, "column": 25 }, + "end": { "line": 1, "column": 27 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 25 }, + "end": { "line": 1, "column": 27 } + } + }, + "openStrip": { "open": false, "close": false }, + "inverseStrip": { "open": false, "close": false }, + "closeStrip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 34 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 34 } + } +} diff --git a/test_fixtures/1.hbs b/test_fixtures/1.hbs new file mode 100644 index 00000000..46d44ed8 --- /dev/null +++ b/test_fixtures/1.hbs @@ -0,0 +1 @@ +{{#if active}}yes{{else}}no{{/if}} \ No newline at end of file diff --git a/test_fixtures/10.ast.json b/test_fixtures/10.ast.json new file mode 100644 index 00000000..053b9072 --- /dev/null +++ b/test_fixtures/10.ast.json @@ -0,0 +1,44 @@ +{ + "type": "Program", + "body": [ + { + "type": "MustacheStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "helper", + "tail": [], + "parts": ["helper"], + "original": "helper", + "loc": { + "start": { "line": 1, "column": 2 }, + "end": { "line": 1, "column": 8 } + } + }, + "params": [ + { + "type": "NumberLiteral", + "value": 42, + "original": 42, + "loc": { + "start": { "line": 1, "column": 9 }, + "end": { "line": 1, "column": 11 } + } + } + ], + "escaped": true, + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 13 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 13 } + } +} diff --git a/test_fixtures/10.hbs b/test_fixtures/10.hbs new file mode 100644 index 00000000..75f92f30 --- /dev/null +++ b/test_fixtures/10.hbs @@ -0,0 +1 @@ +{{helper 42}} \ No newline at end of file diff --git a/test_fixtures/11.ast.json b/test_fixtures/11.ast.json new file mode 100644 index 00000000..79e8e77c --- /dev/null +++ b/test_fixtures/11.ast.json @@ -0,0 +1,53 @@ +{ + "type": "Program", + "body": [ + { + "type": "MustacheStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "helper", + "tail": [], + "parts": ["helper"], + "original": "helper", + "loc": { + "start": { "line": 1, "column": 2 }, + "end": { "line": 1, "column": 8 } + } + }, + "params": [ + { + "type": "BooleanLiteral", + "value": true, + "original": true, + "loc": { + "start": { "line": 1, "column": 9 }, + "end": { "line": 1, "column": 13 } + } + }, + { + "type": "BooleanLiteral", + "value": false, + "original": false, + "loc": { + "start": { "line": 1, "column": 14 }, + "end": { "line": 1, "column": 19 } + } + } + ], + "escaped": true, + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 21 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 21 } + } +} diff --git a/test_fixtures/11.hbs b/test_fixtures/11.hbs new file mode 100644 index 00000000..07843209 --- /dev/null +++ b/test_fixtures/11.hbs @@ -0,0 +1 @@ +{{helper true false}} \ No newline at end of file diff --git a/test_fixtures/12.ast.json b/test_fixtures/12.ast.json new file mode 100644 index 00000000..75c50ffe --- /dev/null +++ b/test_fixtures/12.ast.json @@ -0,0 +1,44 @@ +{ + "type": "Program", + "body": [ + { + "type": "MustacheStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "helper", + "tail": [], + "parts": ["helper"], + "original": "helper", + "loc": { + "start": { "line": 1, "column": 2 }, + "end": { "line": 1, "column": 8 } + } + }, + "params": [ + { + "type": "StringLiteral", + "value": "str", + "original": "str", + "loc": { + "start": { "line": 1, "column": 9 }, + "end": { "line": 1, "column": 14 } + } + } + ], + "escaped": true, + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 16 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 16 } + } +} diff --git a/test_fixtures/12.hbs b/test_fixtures/12.hbs new file mode 100644 index 00000000..02228d52 --- /dev/null +++ b/test_fixtures/12.hbs @@ -0,0 +1 @@ +{{helper "str"}} \ No newline at end of file diff --git a/test_fixtures/13.ast.json b/test_fixtures/13.ast.json new file mode 100644 index 00000000..531fa8fc --- /dev/null +++ b/test_fixtures/13.ast.json @@ -0,0 +1,34 @@ +{ + "type": "Program", + "body": [ + { + "type": "MustacheStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "foo", + "tail": ["bar", "baz"], + "parts": ["foo", "bar", "baz"], + "original": "foo.bar.baz", + "loc": { + "start": { "line": 1, "column": 2 }, + "end": { "line": 1, "column": 13 } + } + }, + "params": [], + "escaped": true, + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 15 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 15 } + } +} diff --git a/test_fixtures/13.hbs b/test_fixtures/13.hbs new file mode 100644 index 00000000..3b66b360 --- /dev/null +++ b/test_fixtures/13.hbs @@ -0,0 +1 @@ +{{foo.bar.baz}} \ No newline at end of file diff --git a/test_fixtures/14.ast.json b/test_fixtures/14.ast.json new file mode 100644 index 00000000..09a36c28 --- /dev/null +++ b/test_fixtures/14.ast.json @@ -0,0 +1,34 @@ +{ + "type": "Program", + "body": [ + { + "type": "MustacheStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 2, + "head": "parent", + "tail": [], + "parts": ["parent"], + "original": "../../parent", + "loc": { + "start": { "line": 1, "column": 2 }, + "end": { "line": 1, "column": 14 } + } + }, + "params": [], + "escaped": true, + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 16 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 16 } + } +} diff --git a/test_fixtures/14.hbs b/test_fixtures/14.hbs new file mode 100644 index 00000000..2bffadf3 --- /dev/null +++ b/test_fixtures/14.hbs @@ -0,0 +1 @@ +{{../../parent}} \ No newline at end of file diff --git a/test_fixtures/15.ast.json b/test_fixtures/15.ast.json new file mode 100644 index 00000000..a68daa4e --- /dev/null +++ b/test_fixtures/15.ast.json @@ -0,0 +1,69 @@ +{ + "type": "Program", + "body": [ + { + "type": "BlockStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "each", + "tail": [], + "parts": ["each"], + "original": "each", + "loc": { + "start": { "line": 1, "column": 3 }, + "end": { "line": 1, "column": 7 } + } + }, + "params": [ + { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "items", + "tail": [], + "parts": ["items"], + "original": "items", + "loc": { + "start": { "line": 1, "column": 8 }, + "end": { "line": 1, "column": 13 } + } + } + ], + "program": { + "type": "Program", + "body": [ + { + "type": "ContentStatement", + "original": "it", + "value": "it", + "loc": { + "start": { "line": 1, "column": 29 }, + "end": { "line": 1, "column": 31 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 29 }, + "end": { "line": 1, "column": 31 } + }, + "blockParams": ["item", "idx"] + }, + "openStrip": { "open": false, "close": false }, + "closeStrip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 40 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 40 } + } +} diff --git a/test_fixtures/15.hbs b/test_fixtures/15.hbs new file mode 100644 index 00000000..0f52200b --- /dev/null +++ b/test_fixtures/15.hbs @@ -0,0 +1 @@ +{{#each items as |item idx|}}it{{/each}} \ No newline at end of file diff --git a/test_fixtures/16.ast.json b/test_fixtures/16.ast.json new file mode 100644 index 00000000..aeb9d04b --- /dev/null +++ b/test_fixtures/16.ast.json @@ -0,0 +1,63 @@ +{ + "type": "Program", + "body": [ + { + "type": "DecoratorBlock", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "inline", + "tail": [], + "parts": ["inline"], + "original": "inline", + "loc": { + "start": { "line": 1, "column": 4 }, + "end": { "line": 1, "column": 10 } + } + }, + "params": [ + { + "type": "StringLiteral", + "value": "foo", + "original": "foo", + "loc": { + "start": { "line": 1, "column": 11 }, + "end": { "line": 1, "column": 16 } + } + } + ], + "program": { + "type": "Program", + "body": [ + { + "type": "ContentStatement", + "original": "bar", + "value": "bar", + "loc": { + "start": { "line": 1, "column": 18 }, + "end": { "line": 1, "column": 21 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 18 }, + "end": { "line": 1, "column": 21 } + } + }, + "openStrip": { "open": false, "close": false }, + "closeStrip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 32 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 32 } + } +} diff --git a/test_fixtures/16.hbs b/test_fixtures/16.hbs new file mode 100644 index 00000000..e6d1ed56 --- /dev/null +++ b/test_fixtures/16.hbs @@ -0,0 +1 @@ +{{#*inline "foo"}}bar{{/inline}} \ No newline at end of file diff --git a/test_fixtures/17.ast.json b/test_fixtures/17.ast.json new file mode 100644 index 00000000..9e6a7bf9 --- /dev/null +++ b/test_fixtures/17.ast.json @@ -0,0 +1,52 @@ +{ + "type": "Program", + "body": [ + { + "type": "ContentStatement", + "original": "before ", + "value": "before ", + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 7 } + } + }, + { + "type": "MustacheStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "name", + "tail": [], + "parts": ["name"], + "original": "name", + "loc": { + "start": { "line": 1, "column": 9 }, + "end": { "line": 1, "column": 13 } + } + }, + "params": [], + "escaped": true, + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 7 }, + "end": { "line": 1, "column": 15 } + } + }, + { + "type": "ContentStatement", + "original": " after", + "value": " after", + "loc": { + "start": { "line": 1, "column": 15 }, + "end": { "line": 1, "column": 21 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 21 } + } +} diff --git a/test_fixtures/17.hbs b/test_fixtures/17.hbs new file mode 100644 index 00000000..24af0f19 --- /dev/null +++ b/test_fixtures/17.hbs @@ -0,0 +1 @@ +before {{name}} after \ No newline at end of file diff --git a/test_fixtures/18.ast.json b/test_fixtures/18.ast.json new file mode 100644 index 00000000..9e6a7bf9 --- /dev/null +++ b/test_fixtures/18.ast.json @@ -0,0 +1,52 @@ +{ + "type": "Program", + "body": [ + { + "type": "ContentStatement", + "original": "before ", + "value": "before ", + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 7 } + } + }, + { + "type": "MustacheStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "name", + "tail": [], + "parts": ["name"], + "original": "name", + "loc": { + "start": { "line": 1, "column": 9 }, + "end": { "line": 1, "column": 13 } + } + }, + "params": [], + "escaped": true, + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 7 }, + "end": { "line": 1, "column": 15 } + } + }, + { + "type": "ContentStatement", + "original": " after", + "value": " after", + "loc": { + "start": { "line": 1, "column": 15 }, + "end": { "line": 1, "column": 21 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 21 } + } +} diff --git a/test_fixtures/18.hbs b/test_fixtures/18.hbs new file mode 100644 index 00000000..24af0f19 --- /dev/null +++ b/test_fixtures/18.hbs @@ -0,0 +1 @@ +before {{name}} after \ No newline at end of file diff --git a/test_fixtures/19.ast.json b/test_fixtures/19.ast.json new file mode 100644 index 00000000..3d1f502c --- /dev/null +++ b/test_fixtures/19.ast.json @@ -0,0 +1,68 @@ +{ + "type": "Program", + "body": [ + { + "type": "BlockStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "each", + "tail": [], + "parts": ["each"], + "original": "each", + "loc": { + "start": { "line": 1, "column": 3 }, + "end": { "line": 1, "column": 7 } + } + }, + "params": [ + { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "items", + "tail": [], + "parts": ["items"], + "original": "items", + "loc": { + "start": { "line": 1, "column": 8 }, + "end": { "line": 1, "column": 13 } + } + } + ], + "program": { + "type": "Program", + "body": [ + { + "type": "ContentStatement", + "original": "item", + "value": "item", + "loc": { + "start": { "line": 1, "column": 15 }, + "end": { "line": 1, "column": 19 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 15 }, + "end": { "line": 1, "column": 19 } + } + }, + "openStrip": { "open": false, "close": false }, + "closeStrip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 28 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 28 } + } +} diff --git a/test_fixtures/19.hbs b/test_fixtures/19.hbs new file mode 100644 index 00000000..e76ca582 --- /dev/null +++ b/test_fixtures/19.hbs @@ -0,0 +1 @@ +{{#each items}}item{{/each}} \ No newline at end of file diff --git a/test_fixtures/2.ast.json b/test_fixtures/2.ast.json new file mode 100644 index 00000000..3d1f502c --- /dev/null +++ b/test_fixtures/2.ast.json @@ -0,0 +1,68 @@ +{ + "type": "Program", + "body": [ + { + "type": "BlockStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "each", + "tail": [], + "parts": ["each"], + "original": "each", + "loc": { + "start": { "line": 1, "column": 3 }, + "end": { "line": 1, "column": 7 } + } + }, + "params": [ + { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "items", + "tail": [], + "parts": ["items"], + "original": "items", + "loc": { + "start": { "line": 1, "column": 8 }, + "end": { "line": 1, "column": 13 } + } + } + ], + "program": { + "type": "Program", + "body": [ + { + "type": "ContentStatement", + "original": "item", + "value": "item", + "loc": { + "start": { "line": 1, "column": 15 }, + "end": { "line": 1, "column": 19 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 15 }, + "end": { "line": 1, "column": 19 } + } + }, + "openStrip": { "open": false, "close": false }, + "closeStrip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 28 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 28 } + } +} diff --git a/test_fixtures/2.hbs b/test_fixtures/2.hbs new file mode 100644 index 00000000..e76ca582 --- /dev/null +++ b/test_fixtures/2.hbs @@ -0,0 +1 @@ +{{#each items}}item{{/each}} \ No newline at end of file diff --git a/test_fixtures/20.ast.json b/test_fixtures/20.ast.json new file mode 100644 index 00000000..e6507626 --- /dev/null +++ b/test_fixtures/20.ast.json @@ -0,0 +1,53 @@ +{ + "type": "Program", + "body": [ + { + "type": "BlockStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "inverted", + "tail": [], + "parts": ["inverted"], + "original": "inverted", + "loc": { + "start": { "line": 1, "column": 3 }, + "end": { "line": 1, "column": 11 } + } + }, + "params": [], + "inverse": { + "type": "Program", + "body": [ + { + "type": "ContentStatement", + "original": "body", + "value": "body", + "loc": { + "start": { "line": 1, "column": 13 }, + "end": { "line": 1, "column": 17 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 13 }, + "end": { "line": 1, "column": 17 } + } + }, + "openStrip": { "open": false, "close": false }, + "closeStrip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 30 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 30 } + } +} diff --git a/test_fixtures/20.hbs b/test_fixtures/20.hbs new file mode 100644 index 00000000..f47ee747 --- /dev/null +++ b/test_fixtures/20.hbs @@ -0,0 +1 @@ +{{^inverted}}body{{/inverted}} \ No newline at end of file diff --git a/test_fixtures/21.ast.json b/test_fixtures/21.ast.json new file mode 100644 index 00000000..6cfa7fec --- /dev/null +++ b/test_fixtures/21.ast.json @@ -0,0 +1,34 @@ +{ + "type": "Program", + "body": [ + { + "type": "PartialStatement", + "name": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "partial", + "tail": [], + "parts": ["partial"], + "original": "partial", + "loc": { + "start": { "line": 1, "column": 4 }, + "end": { "line": 1, "column": 11 } + } + }, + "params": [], + "indent": "", + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 13 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 13 } + } +} diff --git a/test_fixtures/21.hbs b/test_fixtures/21.hbs new file mode 100644 index 00000000..3d95ab42 --- /dev/null +++ b/test_fixtures/21.hbs @@ -0,0 +1 @@ +{{> partial}} \ No newline at end of file diff --git a/test_fixtures/22.ast.json b/test_fixtures/22.ast.json new file mode 100644 index 00000000..7784468e --- /dev/null +++ b/test_fixtures/22.ast.json @@ -0,0 +1,53 @@ +{ + "type": "Program", + "body": [ + { + "type": "PartialBlockStatement", + "name": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "layout", + "tail": [], + "parts": ["layout"], + "original": "layout", + "loc": { + "start": { "line": 1, "column": 5 }, + "end": { "line": 1, "column": 11 } + } + }, + "params": [], + "program": { + "type": "Program", + "body": [ + { + "type": "ContentStatement", + "original": "body", + "value": "body", + "loc": { + "start": { "line": 1, "column": 13 }, + "end": { "line": 1, "column": 17 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 13 }, + "end": { "line": 1, "column": 17 } + } + }, + "openStrip": { "open": false, "close": false }, + "closeStrip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 28 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 28 } + } +} diff --git a/test_fixtures/22.hbs b/test_fixtures/22.hbs new file mode 100644 index 00000000..1d7b44bb --- /dev/null +++ b/test_fixtures/22.hbs @@ -0,0 +1 @@ +{{#> layout}}body{{/layout}} \ No newline at end of file diff --git a/test_fixtures/23.ast.json b/test_fixtures/23.ast.json new file mode 100644 index 00000000..a90db51e --- /dev/null +++ b/test_fixtures/23.ast.json @@ -0,0 +1,80 @@ +{ + "type": "Program", + "body": [ + { + "type": "MustacheStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "helper", + "tail": [], + "parts": ["helper"], + "original": "helper", + "loc": { + "start": { "line": 1, "column": 2 }, + "end": { "line": 1, "column": 8 } + } + }, + "params": [ + { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "param1", + "tail": [], + "parts": ["param1"], + "original": "param1", + "loc": { + "start": { "line": 1, "column": 9 }, + "end": { "line": 1, "column": 15 } + } + } + ], + "hash": { + "type": "Hash", + "pairs": [ + { + "type": "HashPair", + "key": "key", + "value": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "value", + "tail": [], + "parts": ["value"], + "original": "value", + "loc": { + "start": { "line": 1, "column": 20 }, + "end": { "line": 1, "column": 25 } + } + }, + "loc": { + "start": { "line": 1, "column": 16 }, + "end": { "line": 1, "column": 25 } + } + } + ], + "loc": { + "start": { "line": 1, "column": 16 }, + "end": { "line": 1, "column": 25 } + } + }, + "escaped": true, + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 27 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 27 } + } +} diff --git a/test_fixtures/23.hbs b/test_fixtures/23.hbs new file mode 100644 index 00000000..9c56445b --- /dev/null +++ b/test_fixtures/23.hbs @@ -0,0 +1 @@ +{{helper param1 key=value}} \ No newline at end of file diff --git a/test_fixtures/24.ast.json b/test_fixtures/24.ast.json new file mode 100644 index 00000000..053b9072 --- /dev/null +++ b/test_fixtures/24.ast.json @@ -0,0 +1,44 @@ +{ + "type": "Program", + "body": [ + { + "type": "MustacheStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "helper", + "tail": [], + "parts": ["helper"], + "original": "helper", + "loc": { + "start": { "line": 1, "column": 2 }, + "end": { "line": 1, "column": 8 } + } + }, + "params": [ + { + "type": "NumberLiteral", + "value": 42, + "original": 42, + "loc": { + "start": { "line": 1, "column": 9 }, + "end": { "line": 1, "column": 11 } + } + } + ], + "escaped": true, + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 13 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 13 } + } +} diff --git a/test_fixtures/24.hbs b/test_fixtures/24.hbs new file mode 100644 index 00000000..75f92f30 --- /dev/null +++ b/test_fixtures/24.hbs @@ -0,0 +1 @@ +{{helper 42}} \ No newline at end of file diff --git a/test_fixtures/25.ast.json b/test_fixtures/25.ast.json new file mode 100644 index 00000000..79e8e77c --- /dev/null +++ b/test_fixtures/25.ast.json @@ -0,0 +1,53 @@ +{ + "type": "Program", + "body": [ + { + "type": "MustacheStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "helper", + "tail": [], + "parts": ["helper"], + "original": "helper", + "loc": { + "start": { "line": 1, "column": 2 }, + "end": { "line": 1, "column": 8 } + } + }, + "params": [ + { + "type": "BooleanLiteral", + "value": true, + "original": true, + "loc": { + "start": { "line": 1, "column": 9 }, + "end": { "line": 1, "column": 13 } + } + }, + { + "type": "BooleanLiteral", + "value": false, + "original": false, + "loc": { + "start": { "line": 1, "column": 14 }, + "end": { "line": 1, "column": 19 } + } + } + ], + "escaped": true, + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 21 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 21 } + } +} diff --git a/test_fixtures/25.hbs b/test_fixtures/25.hbs new file mode 100644 index 00000000..07843209 --- /dev/null +++ b/test_fixtures/25.hbs @@ -0,0 +1 @@ +{{helper true false}} \ No newline at end of file diff --git a/test_fixtures/26.ast.json b/test_fixtures/26.ast.json new file mode 100644 index 00000000..7e4c09cd --- /dev/null +++ b/test_fixtures/26.ast.json @@ -0,0 +1,72 @@ +{ + "type": "Program", + "body": [ + { + "type": "MustacheStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "helper", + "tail": [], + "parts": ["helper"], + "original": "helper", + "loc": { + "start": { "line": 1, "column": 2 }, + "end": { "line": 1, "column": 8 } + } + }, + "params": [ + { + "type": "SubExpression", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "subexpr", + "tail": [], + "parts": ["subexpr"], + "original": "subexpr", + "loc": { + "start": { "line": 1, "column": 10 }, + "end": { "line": 1, "column": 17 } + } + }, + "params": [ + { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "param", + "tail": [], + "parts": ["param"], + "original": "param", + "loc": { + "start": { "line": 1, "column": 18 }, + "end": { "line": 1, "column": 23 } + } + } + ], + "loc": { + "start": { "line": 1, "column": 9 }, + "end": { "line": 1, "column": 24 } + } + } + ], + "escaped": true, + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 26 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 26 } + } +} diff --git a/test_fixtures/26.hbs b/test_fixtures/26.hbs new file mode 100644 index 00000000..08493755 --- /dev/null +++ b/test_fixtures/26.hbs @@ -0,0 +1 @@ +{{helper (subexpr param)}} \ No newline at end of file diff --git a/test_fixtures/27.ast.json b/test_fixtures/27.ast.json new file mode 100644 index 00000000..aeb9d04b --- /dev/null +++ b/test_fixtures/27.ast.json @@ -0,0 +1,63 @@ +{ + "type": "Program", + "body": [ + { + "type": "DecoratorBlock", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "inline", + "tail": [], + "parts": ["inline"], + "original": "inline", + "loc": { + "start": { "line": 1, "column": 4 }, + "end": { "line": 1, "column": 10 } + } + }, + "params": [ + { + "type": "StringLiteral", + "value": "foo", + "original": "foo", + "loc": { + "start": { "line": 1, "column": 11 }, + "end": { "line": 1, "column": 16 } + } + } + ], + "program": { + "type": "Program", + "body": [ + { + "type": "ContentStatement", + "original": "bar", + "value": "bar", + "loc": { + "start": { "line": 1, "column": 18 }, + "end": { "line": 1, "column": 21 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 18 }, + "end": { "line": 1, "column": 21 } + } + }, + "openStrip": { "open": false, "close": false }, + "closeStrip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 32 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 32 } + } +} diff --git a/test_fixtures/27.hbs b/test_fixtures/27.hbs new file mode 100644 index 00000000..e6d1ed56 --- /dev/null +++ b/test_fixtures/27.hbs @@ -0,0 +1 @@ +{{#*inline "foo"}}bar{{/inline}} \ No newline at end of file diff --git a/test_fixtures/28.ast.json b/test_fixtures/28.ast.json new file mode 100644 index 00000000..a68daa4e --- /dev/null +++ b/test_fixtures/28.ast.json @@ -0,0 +1,69 @@ +{ + "type": "Program", + "body": [ + { + "type": "BlockStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "each", + "tail": [], + "parts": ["each"], + "original": "each", + "loc": { + "start": { "line": 1, "column": 3 }, + "end": { "line": 1, "column": 7 } + } + }, + "params": [ + { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "items", + "tail": [], + "parts": ["items"], + "original": "items", + "loc": { + "start": { "line": 1, "column": 8 }, + "end": { "line": 1, "column": 13 } + } + } + ], + "program": { + "type": "Program", + "body": [ + { + "type": "ContentStatement", + "original": "it", + "value": "it", + "loc": { + "start": { "line": 1, "column": 29 }, + "end": { "line": 1, "column": 31 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 29 }, + "end": { "line": 1, "column": 31 } + }, + "blockParams": ["item", "idx"] + }, + "openStrip": { "open": false, "close": false }, + "closeStrip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 40 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 40 } + } +} diff --git a/test_fixtures/28.hbs b/test_fixtures/28.hbs new file mode 100644 index 00000000..0f52200b --- /dev/null +++ b/test_fixtures/28.hbs @@ -0,0 +1 @@ +{{#each items as |item idx|}}it{{/each}} \ No newline at end of file diff --git a/test_fixtures/29.ast.json b/test_fixtures/29.ast.json new file mode 100644 index 00000000..dee58113 --- /dev/null +++ b/test_fixtures/29.ast.json @@ -0,0 +1,34 @@ +{ + "type": "Program", + "body": [ + { + "type": "MustacheStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "name", + "tail": [], + "parts": ["name"], + "original": "name", + "loc": { + "start": { "line": 1, "column": 3 }, + "end": { "line": 1, "column": 7 } + } + }, + "params": [], + "escaped": true, + "strip": { "open": true, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 9 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 9 } + } +} diff --git a/test_fixtures/29.hbs b/test_fixtures/29.hbs new file mode 100644 index 00000000..3ee32049 --- /dev/null +++ b/test_fixtures/29.hbs @@ -0,0 +1 @@ +{{~name}} \ No newline at end of file diff --git a/test_fixtures/3.ast.json b/test_fixtures/3.ast.json new file mode 100644 index 00000000..e6507626 --- /dev/null +++ b/test_fixtures/3.ast.json @@ -0,0 +1,53 @@ +{ + "type": "Program", + "body": [ + { + "type": "BlockStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "inverted", + "tail": [], + "parts": ["inverted"], + "original": "inverted", + "loc": { + "start": { "line": 1, "column": 3 }, + "end": { "line": 1, "column": 11 } + } + }, + "params": [], + "inverse": { + "type": "Program", + "body": [ + { + "type": "ContentStatement", + "original": "body", + "value": "body", + "loc": { + "start": { "line": 1, "column": 13 }, + "end": { "line": 1, "column": 17 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 13 }, + "end": { "line": 1, "column": 17 } + } + }, + "openStrip": { "open": false, "close": false }, + "closeStrip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 30 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 30 } + } +} diff --git a/test_fixtures/3.hbs b/test_fixtures/3.hbs new file mode 100644 index 00000000..f47ee747 --- /dev/null +++ b/test_fixtures/3.hbs @@ -0,0 +1 @@ +{{^inverted}}body{{/inverted}} \ No newline at end of file diff --git a/test_fixtures/4.ast.json b/test_fixtures/4.ast.json new file mode 100644 index 00000000..6cfa7fec --- /dev/null +++ b/test_fixtures/4.ast.json @@ -0,0 +1,34 @@ +{ + "type": "Program", + "body": [ + { + "type": "PartialStatement", + "name": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "partial", + "tail": [], + "parts": ["partial"], + "original": "partial", + "loc": { + "start": { "line": 1, "column": 4 }, + "end": { "line": 1, "column": 11 } + } + }, + "params": [], + "indent": "", + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 13 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 13 } + } +} diff --git a/test_fixtures/4.hbs b/test_fixtures/4.hbs new file mode 100644 index 00000000..3d95ab42 --- /dev/null +++ b/test_fixtures/4.hbs @@ -0,0 +1 @@ +{{> partial}} \ No newline at end of file diff --git a/test_fixtures/5.ast.json b/test_fixtures/5.ast.json new file mode 100644 index 00000000..7784468e --- /dev/null +++ b/test_fixtures/5.ast.json @@ -0,0 +1,53 @@ +{ + "type": "Program", + "body": [ + { + "type": "PartialBlockStatement", + "name": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "layout", + "tail": [], + "parts": ["layout"], + "original": "layout", + "loc": { + "start": { "line": 1, "column": 5 }, + "end": { "line": 1, "column": 11 } + } + }, + "params": [], + "program": { + "type": "Program", + "body": [ + { + "type": "ContentStatement", + "original": "body", + "value": "body", + "loc": { + "start": { "line": 1, "column": 13 }, + "end": { "line": 1, "column": 17 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 13 }, + "end": { "line": 1, "column": 17 } + } + }, + "openStrip": { "open": false, "close": false }, + "closeStrip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 28 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 28 } + } +} diff --git a/test_fixtures/5.hbs b/test_fixtures/5.hbs new file mode 100644 index 00000000..1d7b44bb --- /dev/null +++ b/test_fixtures/5.hbs @@ -0,0 +1 @@ +{{#> layout}}body{{/layout}} \ No newline at end of file diff --git a/test_fixtures/6.ast.json b/test_fixtures/6.ast.json new file mode 100644 index 00000000..325e4cb0 --- /dev/null +++ b/test_fixtures/6.ast.json @@ -0,0 +1,34 @@ +{ + "type": "Program", + "body": [ + { + "type": "MustacheStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "unescaped", + "tail": [], + "parts": ["unescaped"], + "original": "unescaped", + "loc": { + "start": { "line": 1, "column": 3 }, + "end": { "line": 1, "column": 12 } + } + }, + "params": [], + "escaped": false, + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 15 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 15 } + } +} diff --git a/test_fixtures/6.hbs b/test_fixtures/6.hbs new file mode 100644 index 00000000..e0e01660 --- /dev/null +++ b/test_fixtures/6.hbs @@ -0,0 +1 @@ +{{{unescaped}}} \ No newline at end of file diff --git a/test_fixtures/7.ast.json b/test_fixtures/7.ast.json new file mode 100644 index 00000000..429ee624 --- /dev/null +++ b/test_fixtures/7.ast.json @@ -0,0 +1,19 @@ +{ + "type": "Program", + "body": [ + { + "type": "CommentStatement", + "value": " comment here", + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 18 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 18 } + } +} diff --git a/test_fixtures/7.hbs b/test_fixtures/7.hbs new file mode 100644 index 00000000..770f6876 --- /dev/null +++ b/test_fixtures/7.hbs @@ -0,0 +1 @@ +{{! comment here}} \ No newline at end of file diff --git a/test_fixtures/8.ast.json b/test_fixtures/8.ast.json new file mode 100644 index 00000000..a90db51e --- /dev/null +++ b/test_fixtures/8.ast.json @@ -0,0 +1,80 @@ +{ + "type": "Program", + "body": [ + { + "type": "MustacheStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "helper", + "tail": [], + "parts": ["helper"], + "original": "helper", + "loc": { + "start": { "line": 1, "column": 2 }, + "end": { "line": 1, "column": 8 } + } + }, + "params": [ + { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "param1", + "tail": [], + "parts": ["param1"], + "original": "param1", + "loc": { + "start": { "line": 1, "column": 9 }, + "end": { "line": 1, "column": 15 } + } + } + ], + "hash": { + "type": "Hash", + "pairs": [ + { + "type": "HashPair", + "key": "key", + "value": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "value", + "tail": [], + "parts": ["value"], + "original": "value", + "loc": { + "start": { "line": 1, "column": 20 }, + "end": { "line": 1, "column": 25 } + } + }, + "loc": { + "start": { "line": 1, "column": 16 }, + "end": { "line": 1, "column": 25 } + } + } + ], + "loc": { + "start": { "line": 1, "column": 16 }, + "end": { "line": 1, "column": 25 } + } + }, + "escaped": true, + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 27 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 27 } + } +} diff --git a/test_fixtures/8.hbs b/test_fixtures/8.hbs new file mode 100644 index 00000000..9c56445b --- /dev/null +++ b/test_fixtures/8.hbs @@ -0,0 +1 @@ +{{helper param1 key=value}} \ No newline at end of file diff --git a/test_fixtures/9.ast.json b/test_fixtures/9.ast.json new file mode 100644 index 00000000..7e4c09cd --- /dev/null +++ b/test_fixtures/9.ast.json @@ -0,0 +1,72 @@ +{ + "type": "Program", + "body": [ + { + "type": "MustacheStatement", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "helper", + "tail": [], + "parts": ["helper"], + "original": "helper", + "loc": { + "start": { "line": 1, "column": 2 }, + "end": { "line": 1, "column": 8 } + } + }, + "params": [ + { + "type": "SubExpression", + "path": { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "subexpr", + "tail": [], + "parts": ["subexpr"], + "original": "subexpr", + "loc": { + "start": { "line": 1, "column": 10 }, + "end": { "line": 1, "column": 17 } + } + }, + "params": [ + { + "type": "PathExpression", + "this": false, + "data": false, + "depth": 0, + "head": "param", + "tail": [], + "parts": ["param"], + "original": "param", + "loc": { + "start": { "line": 1, "column": 18 }, + "end": { "line": 1, "column": 23 } + } + } + ], + "loc": { + "start": { "line": 1, "column": 9 }, + "end": { "line": 1, "column": 24 } + } + } + ], + "escaped": true, + "strip": { "open": false, "close": false }, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 26 } + } + } + ], + "strip": {}, + "loc": { + "start": { "line": 1, "column": 0 }, + "end": { "line": 1, "column": 26 } + } +} diff --git a/test_fixtures/9.hbs b/test_fixtures/9.hbs new file mode 100644 index 00000000..08493755 --- /dev/null +++ b/test_fixtures/9.hbs @@ -0,0 +1 @@ +{{helper (subexpr param)}} \ No newline at end of file diff --git a/test_fixtures/comp_0.hbs b/test_fixtures/comp_0.hbs new file mode 100644 index 00000000..2f082306 --- /dev/null +++ b/test_fixtures/comp_0.hbs @@ -0,0 +1 @@ +Hello {{name}}! \ No newline at end of file diff --git a/test_fixtures/comp_0.spec.json b/test_fixtures/comp_0.spec.json new file mode 100644 index 00000000..b0afe668 --- /dev/null +++ b/test_fixtures/comp_0.spec.json @@ -0,0 +1 @@ +"{\"compiler\":[8,\">= 4.3.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n var helper, lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n };\n\n return \"Hello \"\n + container.escapeExpression(((helper = (helper = lookupProperty(helpers,\"name\") || (depth0 != null ? lookupProperty(depth0,\"name\") : depth0)) != null ? helper : container.hooks.helperMissing),(typeof helper === \"function\" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{\"name\":\"name\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":1,\"column\":6},\"end\":{\"line\":1,\"column\":14}}}) : helper)))\n + \"!\";\n},\"useData\":true}" diff --git a/test_fixtures/comp_1.hbs b/test_fixtures/comp_1.hbs new file mode 100644 index 00000000..46d44ed8 --- /dev/null +++ b/test_fixtures/comp_1.hbs @@ -0,0 +1 @@ +{{#if active}}yes{{else}}no{{/if}} \ No newline at end of file diff --git a/test_fixtures/comp_1.spec.json b/test_fixtures/comp_1.spec.json new file mode 100644 index 00000000..8f168e98 --- /dev/null +++ b/test_fixtures/comp_1.spec.json @@ -0,0 +1 @@ +"{\"1\":function(container,depth0,helpers,partials,data) {\n return \"yes\";\n},\"3\":function(container,depth0,helpers,partials,data) {\n return \"no\";\n},\"compiler\":[8,\">= 4.3.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n var stack1, lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n };\n\n return ((stack1 = lookupProperty(helpers,\"if\").call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? lookupProperty(depth0,\"active\") : depth0),{\"name\":\"if\",\"hash\":{},\"fn\":container.program(1, data, 0),\"inverse\":container.program(3, data, 0),\"data\":data,\"loc\":{\"start\":{\"line\":1,\"column\":0},\"end\":{\"line\":1,\"column\":34}}})) != null ? stack1 : \"\");\n},\"useData\":true}" diff --git a/test_fixtures/comp_2.hbs b/test_fixtures/comp_2.hbs new file mode 100644 index 00000000..e0e01660 --- /dev/null +++ b/test_fixtures/comp_2.hbs @@ -0,0 +1 @@ +{{{unescaped}}} \ No newline at end of file diff --git a/test_fixtures/comp_2.spec.json b/test_fixtures/comp_2.spec.json new file mode 100644 index 00000000..c37273b0 --- /dev/null +++ b/test_fixtures/comp_2.spec.json @@ -0,0 +1 @@ +"{\"compiler\":[8,\">= 4.3.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n var stack1, helper, lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n };\n\n return ((stack1 = ((helper = (helper = lookupProperty(helpers,\"unescaped\") || (depth0 != null ? lookupProperty(depth0,\"unescaped\") : depth0)) != null ? helper : container.hooks.helperMissing),(typeof helper === \"function\" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{\"name\":\"unescaped\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":1,\"column\":0},\"end\":{\"line\":1,\"column\":15}}}) : helper))) != null ? stack1 : \"\");\n},\"useData\":true}" diff --git a/test_fixtures/comp_3.hbs b/test_fixtures/comp_3.hbs new file mode 100644 index 00000000..3b66b360 --- /dev/null +++ b/test_fixtures/comp_3.hbs @@ -0,0 +1 @@ +{{foo.bar.baz}} \ No newline at end of file diff --git a/test_fixtures/comp_3.spec.json b/test_fixtures/comp_3.spec.json new file mode 100644 index 00000000..5cc9511c --- /dev/null +++ b/test_fixtures/comp_3.spec.json @@ -0,0 +1 @@ +"{\"compiler\":[8,\">= 4.3.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n var stack1, lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n };\n\n return container.escapeExpression(container.lambda(((stack1 = ((stack1 = (depth0 != null ? lookupProperty(depth0,\"foo\") : depth0)) != null ? lookupProperty(stack1,\"bar\") : stack1)) != null ? lookupProperty(stack1,\"baz\") : stack1), depth0));\n},\"useData\":true}" diff --git a/test_fixtures/comp_4.hbs b/test_fixtures/comp_4.hbs new file mode 100644 index 00000000..24af0f19 --- /dev/null +++ b/test_fixtures/comp_4.hbs @@ -0,0 +1 @@ +before {{name}} after \ No newline at end of file diff --git a/test_fixtures/comp_4.spec.json b/test_fixtures/comp_4.spec.json new file mode 100644 index 00000000..6d5d9090 --- /dev/null +++ b/test_fixtures/comp_4.spec.json @@ -0,0 +1 @@ +"{\"compiler\":[8,\">= 4.3.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n var helper, lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n };\n\n return \"before \"\n + container.escapeExpression(((helper = (helper = lookupProperty(helpers,\"name\") || (depth0 != null ? lookupProperty(depth0,\"name\") : depth0)) != null ? helper : container.hooks.helperMissing),(typeof helper === \"function\" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{\"name\":\"name\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":1,\"column\":7},\"end\":{\"line\":1,\"column\":15}}}) : helper)))\n + \" after\";\n},\"useData\":true}" diff --git a/test_fixtures/comp_5.hbs b/test_fixtures/comp_5.hbs new file mode 100644 index 00000000..e76ca582 --- /dev/null +++ b/test_fixtures/comp_5.hbs @@ -0,0 +1 @@ +{{#each items}}item{{/each}} \ No newline at end of file diff --git a/test_fixtures/comp_5.spec.json b/test_fixtures/comp_5.spec.json new file mode 100644 index 00000000..910f52ac --- /dev/null +++ b/test_fixtures/comp_5.spec.json @@ -0,0 +1 @@ +"{\"1\":function(container,depth0,helpers,partials,data) {\n return \"item\";\n},\"compiler\":[8,\">= 4.3.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n var stack1, lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n };\n\n return ((stack1 = lookupProperty(helpers,\"each\").call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? lookupProperty(depth0,\"items\") : depth0),{\"name\":\"each\",\"hash\":{},\"fn\":container.program(1, data, 0),\"inverse\":container.noop,\"data\":data,\"loc\":{\"start\":{\"line\":1,\"column\":0},\"end\":{\"line\":1,\"column\":28}}})) != null ? stack1 : \"\");\n},\"useData\":true}" diff --git a/test_fixtures/comp_6.hbs b/test_fixtures/comp_6.hbs new file mode 100644 index 00000000..75f92f30 --- /dev/null +++ b/test_fixtures/comp_6.hbs @@ -0,0 +1 @@ +{{helper 42}} \ No newline at end of file diff --git a/test_fixtures/comp_6.spec.json b/test_fixtures/comp_6.spec.json new file mode 100644 index 00000000..46aaf742 --- /dev/null +++ b/test_fixtures/comp_6.spec.json @@ -0,0 +1 @@ +"{\"compiler\":[8,\">= 4.3.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n var lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n };\n\n return container.escapeExpression((lookupProperty(helpers,\"helper\")||(depth0 && lookupProperty(depth0,\"helper\"))||container.hooks.helperMissing).call(depth0 != null ? depth0 : (container.nullContext || {}),42,{\"name\":\"helper\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":1,\"column\":0},\"end\":{\"line\":1,\"column\":13}}}));\n},\"useData\":true}" diff --git a/test_fixtures/comp_7.hbs b/test_fixtures/comp_7.hbs new file mode 100644 index 00000000..08493755 --- /dev/null +++ b/test_fixtures/comp_7.hbs @@ -0,0 +1 @@ +{{helper (subexpr param)}} \ No newline at end of file diff --git a/test_fixtures/comp_7.spec.json b/test_fixtures/comp_7.spec.json new file mode 100644 index 00000000..7ceb0cdd --- /dev/null +++ b/test_fixtures/comp_7.spec.json @@ -0,0 +1 @@ +"{\"compiler\":[8,\">= 4.3.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n var alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n };\n\n return container.escapeExpression((lookupProperty(helpers,\"helper\")||(depth0 && lookupProperty(depth0,\"helper\"))||alias2).call(alias1,(lookupProperty(helpers,\"subexpr\")||(depth0 && lookupProperty(depth0,\"subexpr\"))||alias2).call(alias1,(depth0 != null ? lookupProperty(depth0,\"param\") : depth0),{\"name\":\"subexpr\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":1,\"column\":9},\"end\":{\"line\":1,\"column\":24}}}),{\"name\":\"helper\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":1,\"column\":0},\"end\":{\"line\":1,\"column\":26}}}));\n},\"useData\":true}" diff --git a/test_fixtures/comp_8.hbs b/test_fixtures/comp_8.hbs new file mode 100644 index 00000000..3d95ab42 --- /dev/null +++ b/test_fixtures/comp_8.hbs @@ -0,0 +1 @@ +{{> partial}} \ No newline at end of file diff --git a/test_fixtures/comp_8.spec.json b/test_fixtures/comp_8.spec.json new file mode 100644 index 00000000..8bc1482a --- /dev/null +++ b/test_fixtures/comp_8.spec.json @@ -0,0 +1 @@ +"{\"compiler\":[8,\">= 4.3.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n var stack1, lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n };\n\n return ((stack1 = container.invokePartial(lookupProperty(partials,\"partial\"),depth0,{\"name\":\"partial\",\"data\":data,\"helpers\":helpers,\"partials\":partials,\"decorators\":container.decorators})) != null ? stack1 : \"\");\n},\"usePartial\":true,\"useData\":true}" diff --git a/test_fixtures/comp_9.hbs b/test_fixtures/comp_9.hbs new file mode 100644 index 00000000..e6d1ed56 --- /dev/null +++ b/test_fixtures/comp_9.hbs @@ -0,0 +1 @@ +{{#*inline "foo"}}bar{{/inline}} \ No newline at end of file diff --git a/test_fixtures/comp_9.spec.json b/test_fixtures/comp_9.spec.json new file mode 100644 index 00000000..c3cdacf8 --- /dev/null +++ b/test_fixtures/comp_9.spec.json @@ -0,0 +1 @@ +"{\"1\":function(container,depth0,helpers,partials,data) {\n return \"bar\";\n},\"compiler\":[8,\">= 4.3.0\"],\"main\":function(container,depth0,helpers,partials,data,blockParams,depths) {\n var lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n };\n\n return \"\";\n},\"main_d\": function(fn, props, container, depth0, data, blockParams, depths) {\n\n var decorators = container.decorators, lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n };\n\n fn = lookupProperty(decorators,\"inline\")(fn,props,container,{\"name\":\"inline\",\"hash\":{},\"fn\":container.program(1, data, 0, blockParams, depths),\"inverse\":container.noop,\"args\":[\"foo\"],\"data\":data,\"loc\":{\"start\":{\"line\":1,\"column\":0},\"end\":{\"line\":1,\"column\":32}}}) || fn;\n return fn;\n }\n\n,\"useDecorators\":true,\"useData\":true,\"useDepths\":true}"