How to use @glimmer/compiler - 10 common examples

To help you get started, we’ve selected a few @glimmer/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 bakerac4 / glimmer-native / src / glimmer / context.ts View on Github external
export function Compilable(source: any) {
    // console.log('In Compilable: ' + source);
    const precompiled = precompile(source);
    // console.log('Precompiled');
    const component = Component(precompiled);
    // console.log(`Compiled Component: ${component}`);
    return component;
}
github fkling / astexplorer / website / src / parsers / handlebars / transformers / glimmer-compiler / index.js View on Github external
import compileModule from '../../../utils/compileModule';
import pkg from '@glimmer/compiler/package.json';

const ID = 'glimmer-compiler';

export default {
  id: ID,
  displayName: ID,
  version: pkg.version,
  homepage: pkg.homepage || 'https://github.com/glimmerjs/glimmer-vm',

  defaultParserID: 'glimmer',

  loadTransformer(callback) {
    require(
      ['../../../transpilers/babel', '@glimmer/compiler'],
      (transpile, glimmer) => callback({ transpile: transpile.default, glimmer }),
    );
  },

  transform({ transpile, glimmer }, transformCode, code) {
    transformCode = transpile(transformCode);
    const transformModule = compileModule(transformCode);

    // allow "export default" instead of "module.exports = "
    const transform = transformModule.__esModule ?
github fkling / astexplorer / website / src / parsers / handlebars / transformers / glimmer-compiler / index.js View on Github external
import compileModule from '../../../utils/compileModule';
import pkg from '@glimmer/compiler/package.json';

const ID = 'glimmer-compiler';

export default {
  id: ID,
  displayName: ID,
  version: pkg.version,
  homepage: pkg.homepage || 'https://github.com/glimmerjs/glimmer-vm',

  defaultParserID: 'glimmer',

  loadTransformer(callback) {
    require(
      ['../../../transpilers/babel', '@glimmer/compiler'],
      (transpile, glimmer) => callback({ transpile: transpile.default, glimmer }),
    );
  },

  transform({ transpile, glimmer }, transformCode, code) {
    transformCode = transpile(transformCode);
    const transformModule = compileModule(transformCode);

    // allow "export default" instead of "module.exports = "
github glimmerjs / glimmer-vm / packages / @glimmer / test-helpers / lib / environment.ts View on Github external
compile(template: string, meta: TemplateMeta = {}): Template {
    let wrapper = JSON.parse(precompile(template, { meta }));
    let factory = templateFactory(wrapper);
    return factory.create(this.compileOptions);
  }
github glimmerjs / glimmer-vm / packages / @glimmer / test-helpers / lib / environment / modes / lazy / environment.ts View on Github external
preprocess(
    template: string,
    meta?: AnnotatedModuleLocator
  ): Template> {
    let wrapper = JSON.parse(precompile(template));
    let factory = templateFactory(wrapper);
    return factory.create(templateMeta(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-vm / packages / @glimmer / test-helpers / lib / environment / shared.ts View on Github external
export function createTemplate(templateSource: string, meta: TemplateMeta = {}): ParsedLayout {
  let wrapper: SerializedTemplateWithLazyBlock = JSON.parse(precompile(templateSource, { meta }));
  let block: SerializedTemplateBlock = JSON.parse(wrapper.block);

  return { block, referer: meta };
}
github glimmerjs / glimmer-vm / packages / @glimmer / integration-tests / lib / suites / custom-dom-helper.ts View on Github external
'generates id in node'() {
    let template = precompile('hello');
    let obj = JSON.parse(template);
    this.assert.equal(obj.id, '14+n+4pQ', 'short sha of template source');
    template = precompile('hello', { meta: { moduleName: 'template/hello' } });
    obj = JSON.parse(template);
    this.assert.equal(obj.id, 'Ohs2KKrA', 'short sha of template source and meta');
  }
}
github bakerac4 / glimmer-native / dist / index.js View on Github external
registerNativeComponent(name, value) {
        this.registerNativeElement(name, value);
        const handle = Application.resolver.registerTemplateOnlyComponent(name);
        Application.resolverDelegate.registerComponent(name, handle, precompile(`<${name.toLowerCase()} ...attributes> {{yield}} `), TEMPLATE_ONLY_COMPONENT);
    }
    registerHelper(name, func) {
github glimmerjs / glimmer-application-pipeline / lib / broccoli / glimmer-template-precompiler.ts View on Github external
processString(content, relativePath) {
    let specifier = getTemplateSpecifier(this.options.rootName, relativePath);
    return 'export default ' + precompile(content, { meta: { specifier, '': true } }) + ';';
  }
}

@glimmer/compiler

MIT
Latest version published 2 months ago

Package Health Score

77 / 100
Full package analysis

Similar packages