How to use the @glimmer/syntax.builders.sexpr 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 linkedin / css-blocks / packages / @css-blocks / glimmer / src / ClassnamesHelperGenerator.ts View on Github external
function moustacheToExpression(expr: AST.MustacheStatement): AST.Expression {
  if (expr.path.type === "PathExpression") {
    if (expr.params.length === 0 && expr.hash.pairs.length === 0) {
      debug("converting", expr.path.original, "to path");
      return expr.path;
    } else {
      debug("converting", expr.path.original, "to sexpr");
      return builders.sexpr(expr.path, expr.params, expr.hash);
    }
  } else {
    debug("preserving literal", expr.path.original, "as literal");
    return expr.path;
  }
}
github linkedin / css-blocks / packages / @css-blocks / glimmer / src / ClassnamesHelperGenerator.ts View on Github external
function moustacheToStringExpression(stringExpression: StringAST): AST.Expression {
  if (stringExpression!.type === "ConcatStatement") {
    return builders.sexpr(
      builders.path(CONCAT_HELPER_NAME),
      (stringExpression as AST.ConcatStatement).parts.reduce(
        (arr, val) => {
          if (val.type === "TextNode") {
            arr.push(builders.string(val.chars));
          } else {
            arr.push(val.path);
          }
          return arr;
        },
        new Array()));
  } else {
    return moustacheToExpression(stringExpression as AST.MustacheStatement);
  }
}
github linkedin / css-blocks / packages / @css-blocks / glimmer / src / ClassnamesHelperGenerator.ts View on Github external
export function classnamesSubexpr(rewrite: IndexedClassRewrite<style>, element: TemplateElement): AST.SubExpression {
  return builders.sexpr(
    builders.path(CLASSNAMES_HELPER_NAME),
    constructArgs(rewrite, element),
  );
}
</style>