How to use the @glimmer/interfaces.ExpressionContext.AppendSingleId function in @glimmer/interfaces

To help you get started, we’ve selected a few @glimmer/interfaces 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 / opcode-compiler / lib / syntax / push-resolution.ts View on Github external
switch (expressionContext) {
        case ExpressionContext.Expression: {
          // in classic mode, this is always a this-fallback
          let name = context.meta.upvars![freeVar];

          concatExpressions(
            encoder,
            context,
            [op(Op.GetVariable, 0), op(Op.GetProperty, name)],
            constants
          );

          break;
        }

        case ExpressionContext.AppendSingleId: {
          let resolver = context.syntax.program.resolverDelegate;
          let name = context.meta.upvars![freeVar];

          let resolvedHelper = resolver.lookupHelper(name, context.meta.referrer);
          let expressions: ExpressionCompileActions;

          if (resolvedHelper) {
            expressions = Call({ handle: resolvedHelper, params: null, hash: null });
          } else {
            // in classic mode, this is always a this-fallback
            expressions = [op(Op.GetVariable, 0), op(Op.GetProperty, name)];
          }

          concatExpressions(encoder, context, expressions, constants);

          break;
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / builder.ts View on Github external
return [];
      } else if (val === true) {
        return [[Op.StaticAttr, name, '', namespace]];
      } else if (typeof val === 'string') {
        return [[Op.StaticAttr, name, val, namespace]];
      } else {
        throw new Error(`Unexpected/unimplemented literal attribute ${JSON.stringify(val)}`);
      }
    }

    default:
      return [
        [
          Op.DynamicAttr,
          name,
          buildExpression(value, ExpressionContext.AppendSingleId, symbols),
          namespace,
        ],
      ];
  }
}
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / template-compiler.ts View on Github external
private mustacheAttrValue(value: AST.TextNode | AST.MustacheStatement): value is AST.TextNode {
    if (value.type === 'TextNode') {
      this.opcode(['literal', value.chars]);
      return true;
    } else if (isKeyword(value)) {
      this.keyword(value);
    } else if (isHelperInvocation(value)) {
      this.prepareHelper(value, 'helper');
      this.expression(value.path, ExpressionContext.CallHead, value);
      this.opcode(['helper'], value);
    } else {
      this.expression(value.path, ExpressionContext.AppendSingleId, value);
    }

    return false;
  }
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / template-compiler.ts View on Github external
function mustacheContext(body: AST.Expression): ExpressionContext {
  if (body.type === 'PathExpression') {
    if (body.parts.length > 1 || body.data) {
      return ExpressionContext.Expression;
    } else {
      return ExpressionContext.AppendSingleId;
    }
  } else {
    return ExpressionContext.Expression;
  }
}
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / builder-interface.ts View on Github external
export function normalizeStatement(statement: BuilderStatement): NormalizedStatement {
  if (Array.isArray(statement)) {
    if (statementIsExpression(statement)) {
      return normalizeAppendExpression(statement, ExpressionContext.AppendSingleId);
    } else if (isSugaryArrayStatement(statement)) {
      return normalizeSugaryArrayStatement(statement);
    } else {
      return normalizeVerboseStatement(statement);
    }
  } else if (typeof statement === 'string') {
    return {
      kind: HeadKind.AppendPath,
      path: normalizeDottedPath(statement),
      trusted: false,
    };
  } else {
    throw assertNever(statement);
  }
}