Skip to content

Commit 7a8ac6c

Browse files
committed
adding a test for content-tag behavior too
1 parent 7802081 commit 7a8ac6c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

__tests__/tests.ts

+33
Original file line numberDiff line numberDiff line change
@@ -2181,6 +2181,39 @@ describe('htmlbars-inline-precompile', function () {
21812181
`);
21822182
});
21832183

2184+
it('expression form can capture lexical "this"', function () {
2185+
plugins = [
2186+
[
2187+
HTMLBarsInlinePrecompile,
2188+
{
2189+
compiler,
2190+
targetFormat: 'hbs',
2191+
},
2192+
],
2193+
];
2194+
2195+
let p = new Preprocessor();
2196+
2197+
let transformed = transform(
2198+
p.process(
2199+
`import HelloWorld from 'somewhere';
2200+
export function example() {
2201+
return <template>{{this.message}}</template>;
2202+
}
2203+
`
2204+
)
2205+
);
2206+
2207+
expect(transformed).toEqualCode(`
2208+
import { precompileTemplate } from "@ember/template-compilation";
2209+
import { setComponentTemplate } from "@ember/component";
2210+
import templateOnly from "@ember/component/template-only";
2211+
export function example() {
2212+
return setComponentTemplate(precompileTemplate('{{this.message}}', { strictMode: true, scope: () => ({ "this": this }) }), templateOnly());
2213+
}
2214+
`);
2215+
});
2216+
21842217
it('works for class member form', function () {
21852218
plugins = [
21862219
[

0 commit comments

Comments
 (0)