How to use the @glimmer/syntax.isLiteral 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 glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / template-compiler.ts View on Github external
mustacheExpression(expr: AST.MustacheStatement) {
    let { path } = expr;

    if (isLiteral(path)) {
      this.opcode('literal', expr, path.value);
    } else if (isBuiltInHelper(path)) {
      this.builtInHelper(expr as AST.Call);
    } else if (isArg(path)) {
      this.arg([path]);
    } else if (isHelperInvocation(expr)) {
      this.prepareHelper(expr);
      this.opcode('helper', expr, path.parts[0]);
    } else if (path.this) {
      this.opcode('get', expr, 0, path.parts);
    } else if (isLocal(path, this.symbols)) {
      let [head, ...parts] = path.parts;
      this.opcode('get', expr, this.symbols.get(head), parts);
    } else if (isSimplePath(path)) {
      this.opcode('unknown', expr, path.parts[0]);
    } else {
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / template-compiler.ts View on Github external
private expression(path: AST.Expression, context: ExpressionContext, expr: AST.Node) {
    if (isLiteral(path)) {
      this.opcode(['literal', path.value], expr);
    } else if (path.type !== 'PathExpression') {
      throw new SyntaxError(`Expected PathExpression, got ${path.type}`, path.loc);
    } else if (isKeyword(expr)) {
      this.keyword(expr as AST.Call);
    } else {
      this.path(path, context);
    }
  }
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / strict-template-compiler.ts View on Github external
mustacheExpression(expr: AST.MustacheStatement) {
    let { path } = expr;

    if (isLiteral(path)) {
      this.opcode(['literal', path.value], expr);
    } else if (isKeyword(path)) {
      this.keyword(expr as AST.Call);
    } else if (isArgReference(path)) {
      this.argReference([path]);
    } else if (isInvocation(expr)) {
      this.prepareInvocation(expr);
      this.opcode(['helper', path.parts[0]], expr);
    } else if (path.this) {
      this.opcode(['get', [0, path.parts]], expr);
    } else {
      let [head, ...parts] = path.parts;
      this.opcode(['freeVariable', [head, ...parts]], expr);
    }
  }
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / template-compiler.ts View on Github external
mustache([mustache]: [AST.MustacheStatement]) {
    let { path } = mustache;

    if (isLiteral(path)) {
      this.expression(mustache.path, ExpressionContext.Expression, mustache);
      this.opcode(['append', !mustache.escaped], mustache);
    } else if (path.type !== 'PathExpression') {
      throw new SyntaxError(`Expected PathExpression, got ${path.type}`, path.loc);
    } else if (isYield(path)) {
      let to = assertValidYield(mustache);
      this.yield(to, mustache);
    } else if (isPartial(path)) {
      let params = assertValidPartial(mustache);
      this.partial(params, mustache);
    } else if (isDebugger(path)) {
      assertValidDebuggerUsage(mustache);
      this.debugger('debugger', mustache);
    } else if (isKeyword(mustache)) {
      this.keyword(mustache);
      this.opcode(['append', !mustache.escaped], mustache);