2026-02-10 13:31:53 +00:00
# Scape Templates — Project Milestones
This document outlines the phased roadmap for building Scape Templates. Each milestone is designed to ensure "Excellence over Features," focusing on a solid foundation before adding complexity.
2026-02-12 05:42:28 +00:00
## Table of Contents
- [Phase 1: Core Architecture & Environment ](#phase-1-core-architecture--environment )
- [Phase 2: Lexical Analysis & Tokenization ](#phase-2-lexical-analysis--tokenization )
- [Phase 3: The AST & Parser ](#phase-3-the-ast--parser )
- [Phase 4: The Interpreter (Rendering Engine) ](#phase-4-the-interpreter-rendering-engine )
- [Phase 5: Inheritance & Reusability ](#phase-5-inheritance--reusability )
- [Phase 6: Extensibility & Performance ](#phase-6-extensibility--performance )
- [Phase 7: Final Polish & Release ](#phase-7-final-polish--release )
2026-02-10 13:31:53 +00:00
## Phase 1: Core Architecture & Environment
*Focus: Establishing the contracts, error handling, and runtime configuration.*
2026-02-12 05:42:28 +00:00
- [x] Define and implement `Scape\Interfaces\FilterInterface` and `Scape\Interfaces\HostProviderInterface` .
- [x] Implement the Exception hierarchy in `Scape\Exceptions` .
- [x] Implement `Scape\Config` to handle environment variables (`SCAPE_*_DIR`) and programmatic overrides.
- [x] Create the `Scape\Engine` boilerplate with the `render()` method signature.
2026-02-10 13:31:53 +00:00
## Phase 2: Lexical Analysis & Tokenization
*Focus: Turning template strings into a stream of tokens that the parser can understand.*
2026-02-12 05:42:28 +00:00
- [x] Implement `Scape\Parser\Lexer` to identify interpolation `{{ }}` , raw `{{{ }}}` , logic `{( )}` , and block `{[ ]}` tags.
- [x] Support white-space independence within tags.
- [x] Implement the white-space control rule (logic tags consuming one trailing newline).
- [x] Comprehensive unit tests for all tag variations.
2026-02-10 13:31:53 +00:00
## Phase 3: The AST & Parser
*Focus: Building the Abstract Syntax Tree (AST) representing the template's structure.*
2026-02-12 05:42:28 +00:00
- [x] Implement `Scape\Parser\Parser` to convert tokens into an AST.
- [x] Define AST Nodes (Text, Variable, Loop, Block, Include, Filter).
- [x] Implement the `foreach` grammar (with optional keys).
- [x] Implement data access logic (dot-notation for objects, brackets for arrays).
2026-02-10 13:31:53 +00:00
## Phase 4: The Interpreter (Rendering Engine)
*Focus: Turning the AST and data into the final HTML output.*
2026-02-12 05:42:28 +00:00
- [x] Implement the AST Interpreter to walk the tree and resolve variables.
- [x] Implement standard HTML escaping (`ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5`).
- [x] Implement Loop logic with `index` , `pos` , and positional rendering (`first`, `inner` , `last` ).
- [x] Implement `debug` vs `production` variable access modes.
2026-02-10 13:31:53 +00:00
## Phase 5: Inheritance & Reusability
*Focus: Blocks, Layouts, and Partials.*
2026-02-12 05:42:28 +00:00
- [x] Implement `{[ extends ]}` and the Block override system (including `{[ parent ]}` ).
- [x] Implement `{[ include ]}` with data scoping rules (`with context`, `with data_source` , inline arrays).
- [x] Implement the recursion limit check (default 20).
- [x] Implement the 404 fallback mechanism.
2026-02-10 13:31:53 +00:00
## Phase 6: Extensibility & Performance
*Focus: Filters, Host IoC, and Caching.*
2026-02-12 05:42:28 +00:00
- [x] Implement the Filter pipeline (piping and arguments).
- [x] Implement `uses` and `load_filter` mechanisms.
- [x] Implement the `host` namespace delegation.
- [x] Implement AST Caching (local storage in `.scape/cache` ) with `mtime` invalidation for dev mode.
2026-02-10 13:31:53 +00:00
## Phase 7: Final Polish & Release
2026-02-12 05:42:28 +00:00
- [x] Final project-wide code style audit.
- [x] Ensure 100% test coverage for core rendering logic.
- [x] Draft the final README (Getting Started and examples).