How to use the @glimmer/opcode-compiler.templateFactory function in @glimmer/opcode-compiler

To help you get started, we’ve selected a few @glimmer/opcode-compiler 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 / compile.ts View on Github external
export function preprocess(
  template: string,
  meta?: AnnotatedModuleLocator
): Template {
  let wrapper = JSON.parse(rawPrecompile(template));
  let factory = templateFactory(wrapper);
  return factory.create(meta || DEFAULT_TEST_META);
}
github glimmerjs / glimmer-vm / packages / @glimmer / integration-tests / lib / compile.ts View on Github external
export function createTemplate(
  templateSource: string,
  options?: PrecompileOptions
): TemplateFactory {
  let wrapper: SerializedTemplateWithLazyBlock = JSON.parse(
    rawPrecompile(templateSource, options)
  );
  return templateFactory(wrapper);
}
github glimmerjs / glimmer.js / packages / @glimmer / application / src / loaders / runtime-compiler / resolver.ts View on Github external
export function createTemplate(
  templateSource: string,
  options?: PrecompileOptions
): TemplateFactory {
  let wrapper: SerializedTemplateWithLazyBlock = JSON.parse(
    precompile(templateSource, options)
  );
  return templateFactory(wrapper);
}
github glimmerjs / glimmer.js / packages / @glimmer / application / src / loaders / runtime-compiler / resolver.ts View on Github external
export function createJitComponentDefinition(
  name: string,
  serializedTemplate: SerializedTemplateWithLazyBlock,
  componentFactory: ComponentFactory,
  owner?: Owner
): ComponentDefinition {
  const template = templateFactory(serializedTemplate).create();

  if (!componentFactory) {
    return new TemplateOnlyComponentDefinition(name, template);
  }

  const ComponentClass = componentFactory.class;
  const { factory } = getManager(ComponentClass);
  return new CustomComponentDefinition(
    name,
    componentFactory,
    factory(owner) as ManagerDelegate,
    template
  );
}
github glimmerjs / glimmer.js / packages / @glimmer / application / src / loaders / runtime-compiler / resolver-delegate.ts View on Github external
lookupComponent(name: string, referrer: Specifier): Option {
    const component = this.lookupComponentDefinition(name, referrer);
    const definition: ComponentDefinition = this.resolver.resolve(component);

    let template;

    if (isAotComponentDefinition(definition)) {
      template = templateFactory(
        this.resolver.resolve>(definition.handle)
      ).create();
    } else {
      template = definition.template;
    }

    return {
      handle: component,
      capabilities: definition.manager.getCapabilities(definition.state),
      compilable: template.asLayout(),
    };
  }