How to use the @glimmer/reference.ConstReference function in @glimmer/reference

To help you get started, we’ve selected a few @glimmer/reference examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glimmerjs / glimmer-vm / packages / @glimmer / integration-tests / lib / suites / entry-point.ts View on Github external
'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');
  }
}
github emberjs / ember.js / packages / ember-glimmer / lib / syntax / render.js View on Github external
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));
  }
}
github emberjs / ember.js / packages / ember-glimmer / lib / helpers / outlet.ts View on Github external
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));
}
github emberjs / ember.js / packages / @ember / -internals / glimmer / lib / syntax / outlet.ts View on Github external
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
  );
}