emberjs/ember.js · error

Invalid block parameters syntax: expecting at least one spac

Error message

Invalid block parameters syntax: expecting at least one space character between "as" and "|"

What it means

When the parser sees `as` at the end of an attribute name and the very next character is `|` with no whitespace between them (e.g. `<Foo as|bar|>`), it throws. Following Handlebars conventions, at least one space is required between `as` and the opening pipe.

Source

Thrown at packages/@glimmer/syntax/lib/parser/tokenizer-event-handlers.ts:368

    const element = this.currentStartTag;
    const as = this.currentAttr;

    let state = { state: 'PossibleAs' } as State;

    const handlers = {
      PossibleAs: (next: string) => {
        assert(state.state === 'PossibleAs', 'bug in block params parser');

        if (isSpace(next)) {
          // " as ..."
          state = { state: 'BeforeStartPipe' };
          this.tokenizer.transitionTo(AFTER_ATTRIBUTE_NAME);
          this.tokenizer.consume();
        } else if (next === '|') {
          // " as|..."
          // Following Handlebars and require a space between "as" and the pipe
          throw generateSyntaxError(
            `Invalid block parameters syntax: expecting at least one space character between "as" and "|"`,
            as.start.until(this.offset().move(1))
          );
        } else {
          // " as{{...", " async...", " as=...", " as>...", " as/>..."
          // Don't consume, let the normal tokenizer code handle the next steps
          state = { state: 'Done' };
        }
      },

      BeforeStartPipe: (next: string) => {
        assert(state.state === 'BeforeStartPipe', 'bug in block params parser');

        if (isSpace(next)) {
          this.tokenizer.consume();
        } else if (next === '|') {
          state = { state: 'BeforeBlockParamName' };
          this.tokenizer.transitionTo(BEFORE_ATTRIBUTE_NAME);

View on GitHub (pinned to 26f97246a8)

Solutions

  1. Insert a space between `as` and the opening pipe: `<Foo as |bar|>`

Example fix

// before
<Foo as|bar|>{{bar}}</Foo>
// after
<Foo as |bar|>{{bar}}</Foo>
Defensive patterns

Strategy: validation

Validate before calling

// Require a space between `as` and the opening pipe
if (/<[^>]*as\|/.test(template)) {
  throw new Error('Expected space between "as" and "|"');
}

Prevention

When it happens

Trigger: parsePossibleBlockParams, reached via appendToAttributeName, when in the block-params state the next consumed character is `|` immediately following `as` — templates like `<Foo as|a b|>` or `<Foo as|a|>`.

Common situations: Compact one-line templates where the author omits the space for brevity; minifiers or hand-editors squeezing out whitespace; confusion with other languages where `as|` is acceptable.

Related errors


AI-assisted analysis of emberjs/ember.js@26f97246a8 (2026-09-01). Data as JSON: /api/errors/c5a77a18a911a0ce. Report an issue: GitHub.