How to use the @glimmer/syntax.builders function in @glimmer/syntax

To help you get started, we’ve selected a few @glimmer/syntax 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 ember-codemods / ember-angle-brackets-codemod / transforms / angle-brackets / angle-brackets-syntax.js View on Github external
module.exports = function(fileInfo, api, options) {
  const config = new Config(options);

  if (shouldSkipFile(fileInfo, config)) {
    return fileInfo.source;
  }

  const ast = glimmer.preprocess(fileInfo.source, {
    mode: 'codemod',
    parseOptions: { ignoreStandalone: true },
  });
  const b = glimmer.builders;

  /**
   * Transform the attributes names & values properly
   */
  const transformAttrs = attrs => {
    return attrs.map(a => {
      let _key = a.key;
      let _valueType = a.value.type;
      let _value;
      if (!isAttribute(a.key)) {
        _key = `@${_key}`;
      }

      if (_valueType === 'PathExpression') {
        _value = b.mustache(b.path(a.value.original));
      } else if (_valueType === 'SubExpression') {