Skip to content

Add {% include path %} directive support to template parser#13

Closed
C0DK wants to merge 3 commits into
mainfrom
claude/add-template-includes-fNtwW
Closed

Add {% include path %} directive support to template parser#13
C0DK wants to merge 3 commits into
mainfrom
claude/add-template-includes-fNtwW

Conversation

@C0DK

@C0DK C0DK commented Mar 20, 2026

Copy link
Copy Markdown
Owner

Implements the include directive that inlines another template file's
content at parse time, as if it were written directly in the template.

  • Parser: handles {% include path %} by resolving relative (to the
    current file directory) or root-relative (to project root) paths,
    reading the target file via an injectable fileReader delegate, and
    recursively parsing it into the AST. Includes circular include
    detection.
  • ClassGenerator: accepts fileDirectory, projectRoot, fileReader, and
    filePath to pass through to Parser.
  • FileGenerator: supplies the file's directory, project root (from
    MSBuildProjectDirectory MSBuild property), and a File.ReadAllText
    reader to ClassGenerator.
  • Tests: Parser unit tests for include resolution, relative/absolute
    paths, circular detection, and missing file errors. Integration tests
    via OutputGenerator with temp files, and end-to-end via sample
    GreetingWithInclude.html that includes GreetingFragment.html.

https://claude.ai/code/session_01BY3CHmYq7DCxZNVmJFP7sy

claude added 3 commits March 20, 2026 13:20
Implements the include directive that inlines another template file's
content at parse time, as if it were written directly in the template.

- Parser: handles {% include path %} by resolving relative (to the
  current file directory) or root-relative (to project root) paths,
  reading the target file via an injectable fileReader delegate, and
  recursively parsing it into the AST. Includes circular include
  detection.
- ClassGenerator: accepts fileDirectory, projectRoot, fileReader, and
  filePath to pass through to Parser.
- FileGenerator: supplies the file's directory, project root (from
  MSBuildProjectDirectory MSBuild property), and a File.ReadAllText
  reader to ClassGenerator.
- Tests: Parser unit tests for include resolution, relative/absolute
  paths, circular detection, and missing file errors. Integration tests
  via OutputGenerator with temp files, and end-to-end via sample
  GreetingWithInclude.html that includes GreetingFragment.html.

https://claude.ai/code/session_01BY3CHmYq7DCxZNVmJFP7sy
ParserTests.cs → ParserTests (literals, variables, GetVariables)
                + ParserConditionalTests (if/unless/else blocks)
                + ParserErrorTests (invalid syntax, error positions)
                + ParserIncludeTests (include directive)

FileGeneratorTests.cs → FileGeneratorConfigurationTests (namespace, visibility)
                      + FileGeneratorRenderingTests (variables, arrays, optionals)
                      + FileGeneratorConditionalTests (if/unless/else rendering)
                      + FileGeneratorIncludeTests (include directive)
                      + FileGeneratorDiagnosticsTests (SB003 diagnostics, deduplication)

https://claude.ai/code/session_01BY3CHmYq7DCxZNVmJFP7sy
Include tag is a {%...%} match, so Parse() always wraps the result in
a CompositeTemplateNode. Tests expecting a bare LiteralTemplateNode were
wrong — fixed to unwrap the single node from the composite.

Also applies CSharpier formatting across all modified files.

https://claude.ai/code/session_01BY3CHmYq7DCxZNVmJFP7sy
@C0DK

C0DK commented Mar 24, 2026

Copy link
Copy Markdown
Owner Author

i dont like this slob.

@C0DK C0DK closed this Mar 24, 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