Skip to content

Commit f488528

Browse files
committed
try to make it less strict
1 parent 443a2ee commit f488528

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

addon/components/dynamic-template.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { createTemplateFactory } from '@ember/template-factory';
66
const { getTemplateLocals } = importSync('@glimmer/syntax');
77
const { precompileJSON } = importSync('@glimmer/compiler');
88

9+
import DynamicTemplateError from './dynamic-template-error';
10+
import ColorPallet from './color-pallet';
11+
912
let templateOwnerMap = new Map();
1013

1114
export default class DynamicTemplateComponent extends Component {
@@ -75,11 +78,11 @@ export default class DynamicTemplateComponent extends Component {
7578

7679
// copied from https://github.com/NullVoxPopuli/limber/blob/main/packages/ember-repl/addon/src/compile/formats/hbs.ts
7780
function compileTemplate(source, { moduleName, scope = {} }) {
78-
let localScope = { ...scope };
81+
let localScope = { DynamicTemplateError, ColorPallet, ...scope };
7982
let locals = getTemplateLocals(source);
8083

8184
let options = {
82-
strictMode: true,
85+
strictMode: false,
8386
moduleName,
8487
locals,
8588
isProduction: false,
@@ -91,14 +94,6 @@ function compileTemplate(source, { moduleName, scope = {} }) {
9194

9295
let usedScope = usedLocals.map((key) => {
9396
let value = localScope[key];
94-
95-
if (!value) {
96-
throw new Error(
97-
`Attempt to use ${key} in compiled hbs, but it was not available in scope. ` +
98-
`Available scope includes: ${Object.keys(localScope)}`,
99-
);
100-
}
101-
10297
return value;
10398
});
10499

@@ -108,7 +103,7 @@ function compileTemplate(source, { moduleName, scope = {} }) {
108103
block: blockJSON,
109104
moduleName: moduleName ?? '(dynamically compiled component)',
110105
scope: () => usedScope,
111-
isStrictMode: true,
106+
isStrictMode: false,
112107
};
113108

114109
let factory = createTemplateFactory(templateJSONObject);

0 commit comments

Comments
 (0)