Skip to content

Improve template exceptions with original source mapping across extends#1

Draft
Copilot wants to merge 17 commits into
mainfrom
copilot/verificar-e-melhorar-estrutura
Draft

Improve template exceptions with original source mapping across extends#1
Copilot wants to merge 17 commits into
mainfrom
copilot/verificar-e-melhorar-estrutura

Conversation

Copy link
Copy Markdown

Copilot AI commented May 27, 2026

Template errors were surfacing from merged/compiled output, making it hard to locate the real fault—especially when the bug lived in a parent layout (extends). This change makes syntax/parser failures report the original template file, line, and column where the error actually exists.

  • Source-aware inheritance merge

    • Added source-map preservation while resolving extends and block overrides.
    • Kept character-level origin metadata through parent/child composition so downstream stages can attribute failures to the correct file.
  • Lexer-level source metadata

    • Lexer::tokenize() now accepts optional source mapping and annotates tokens with:
      • source_file
      • source_line
      • source_column
    • Lexer syntax failures now emit location-aware SyntaxException messages with contextual snippet.
  • Stronger syntax exception model

    • Refactored SyntaxException to support structured location/context construction (fromLocation(...)).
    • Renderer now raises syntax errors via location-aware construction for consistent error shape.
  • Parser exceptions with exact origin

    • Parser errors now include template-origin coordinates from token metadata.
    • Unclosed control-tag errors now report where the opening tag was declared (including parent layout files), not only parser cursor state.
  • Clearer extends-chain failures

    • Improved parent-missing/circular-extends messages to include both referenced parent and referencing template path for faster traceability.
  • Docs

    • Updated README to state that extends-driven errors now point to the original template source location.
throw SyntaxException::fromLocation(
    $templateFile,
    $line,
    $column,
    $snippet,
    $details
);

Copilot AI changed the title Stabilize template engine pipeline (lexer/parser/compiler) and harden runtime path/cache handling refactor: self-compiling nodes, NodeVisitor pattern, thin Compiler orchestrator May 27, 2026
Copilot AI requested a review from beobles May 27, 2026 02:21
Copilot AI changed the title refactor: self-compiling nodes, NodeVisitor pattern, thin Compiler orchestrator Remove Beobles namespace prefix and standardize on Core\View May 27, 2026
Copilot AI changed the title Remove Beobles namespace prefix and standardize on Core\View Handle extends/import directives as full statements during lexing May 27, 2026
Copilot AI changed the title Handle extends/import directives as full statements during lexing Implement real extends inheritance and correct <Block> rendering semantics May 27, 2026
Copilot AI changed the title Implement real extends inheritance and correct <Block> rendering semantics Fix template inheritance caching: invalidate child cache on parent layout changes May 27, 2026
Copilot AI changed the title Fix template inheritance caching: invalidate child cache on parent layout changes Fortalecer herança/caching de templates e endurecer parser/lexer para sintaxe confiável May 27, 2026
Copilot AI changed the title Replace eval-based template rendering with compiled-file execution Harden template rendering with pre-include syntax validation and precise SyntaxException reporting May 27, 2026
Copilot AI changed the title Harden template rendering with pre-include syntax validation and precise SyntaxException reporting Harden template render pipeline with precise syntax diagnostics and SAPI-safe linting May 27, 2026
…reach

- Lexer extractTag: replaced [^>]* regex with character-scanner that handles
  '>' inside quoted attribute values and {{ }} expressions (e.g. <If condition="{{ a > b }}">)
- Parser parseCloseTag: silently ignore </ElseIf> instead of throwing an exception
- ForeachNode: inject $__loop object (index, count, total, first, last, even, odd,
  percentage) at the top of each iteration; use a stack to restore $__loop for
  nested foreach loops
- CloseTagNode: restore $__loop from stack when closing a Foreach
- SYNTAX.md: fix associative-array example (as="value,key") to match actual engine
  convention (first var = value, second = key)
Copilot AI changed the title Harden template render pipeline with precise syntax diagnostics and SAPI-safe linting fix: lexer tag scanner, ElseIf close tag, Foreach $__loop, and SYNTAX.md correction Jun 2, 2026
Copilot AI changed the title fix: lexer tag scanner, ElseIf close tag, Foreach $__loop, and SYNTAX.md correction Fix Lexer: }} / !} inside quoted strings terminates expression prematurely Jun 2, 2026
Copilot stopped work on behalf of beobles due to an error June 2, 2026 19:30
Copilot AI changed the title Fix Lexer: }} / !} inside quoted strings terminates expression prematurely Refactor View core for clearer responsibilities and production-safe error handling Jun 2, 2026
Copilot AI changed the title Refactor View core for clearer responsibilities and production-safe error handling Improve template exceptions with original source mapping across extends Jun 2, 2026
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.

2 participants