Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'supports passing in an initial dynamic context'() {
let delegate = new AotRenderDelegate();
delegate.registerComponent('Basic', 'Basic', 'Locale', `{{-get-dynamic-var "locale"}}`);
let element = delegate.getInitialElement();
let dynamicScope = new DefaultDynamicScope({
locale: new ConstReference('en_US'),
});
delegate.renderComponent('Locale', {}, element, dynamicScope);
QUnit.assert.equal((element as Element).innerHTML, 'en_US');
}
}
let controllerName;
if (args.named.has('controller')) {
let controllerNameRef = args.named.get('controller');
assert(`The controller argument for {{render}} must be quoted, e.g. {{render "sidebar" controller="foo"}}.`, isConst(controllerNameRef));
controllerName = controllerNameRef.value();
assert(`The controller name you supplied '${controllerName}' did not resolve to a controller.`, env.owner.hasRegistration(`controller:${controllerName}`));
} else {
controllerName = templateName;
}
if (args.positional.length === 1) {
return new ConstReference(new RenderDefinition(controllerName, template, env, SINGLETON_RENDER_MANAGER));
} else {
return new ConstReference(new RenderDefinition(controllerName, template, env, NON_SINGLETON_RENDER_MANAGER));
}
}
export default function outlet(vm: VM, args: Arguments) {
let scope = vm.dynamicScope() as DynamicScope;
let nameRef: Reference;
if (args.positional.length === 0) {
nameRef = new ConstReference('main');
} else {
nameRef = args.positional.at>(0);
}
return new OutletComponentReference(new OutletReference(scope.outletState, nameRef));
}
export function outletHelper(vm: VM, args: Arguments) {
let scope = vm.dynamicScope() as DynamicScope;
let nameRef: Reference;
if (args.positional.length === 0) {
nameRef = new ConstReference('main');
} else {
nameRef = args.positional.at>(0);
}
return new OutletComponentReference(
new OutletReference(scope.outletState, nameRef),
vm.env as Environment
);
}