Skip to content

fix(angular): use regex-based else-if pattern matching to match Angular's ELSE_IF_PATTERN#36

Merged
Brooooooklyn merged 1 commit intomainfrom
fix/angular-else-if-pattern-matching
Feb 24, 2026
Merged

fix(angular): use regex-based else-if pattern matching to match Angular's ELSE_IF_PATTERN#36
Brooooooklyn merged 1 commit intomainfrom
fix/angular-else-if-pattern-matching

Conversation

@Brooooooklyn
Copy link
Member

@Brooooooklyn Brooooooklyn commented Feb 24, 2026

Angular uses the regex /^else[^\S\r\n]+if/ to detect "else if" connected
blocks, which means block names like "else ifx" also match as chained
else-if branches. Our parser was using exact string matching ("else if"),
causing names like "else ifx" to fall through to the default BlockType::If
and emit two independent conditionals instead of a single chained one.

Fix by reusing is_else_if_pattern() (made public) in the parser's block
type classification, matching Angular's regex-based connected-block detection.

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com


Note

Low Risk
Small, well-scoped change to control-flow block classification with a targeted regression test; low risk outside of slight behavior changes for unusual @else … block names.

Overview
Aligns @else if connected-block detection with Angular by switching from exact string matching ("else if") to regex-equivalent prefix matching via is_else_if_pattern() when classifying block types.

Exports is_else_if_pattern() from control_flow.rs for reuse in the HTML parser and adds a regression test ensuring inputs like @else ifx (...) are still chained as an ElseIf branch (mirroring Angular behavior).

Written by Cursor Bugbot for commit 5c4bf54. This will update automatically on new commits. Configure here.

…ar's ELSE_IF_PATTERN

Angular uses the regex `/^else[^\S\r\n]+if/` to detect "else if" connected
blocks, which means block names like "else ifx" also match as chained
else-if branches. Our parser was using exact string matching ("else if"),
causing names like "else ifx" to fall through to the default BlockType::If
and emit two independent conditionals instead of a single chained one.

Fix by reusing `is_else_if_pattern()` (made public) in the parser's block
type classification, matching Angular's regex-based connected-block detection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Brooooooklyn Brooooooklyn merged commit 7828f59 into main Feb 24, 2026
4 checks passed
@Brooooooklyn Brooooooklyn deleted the fix/angular-else-if-pattern-matching branch February 24, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant