Add {% include path %} directive support to template parser#13
Closed
C0DK wants to merge 3 commits into
Closed
Conversation
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
Owner
Author
|
i dont like this slob. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the include directive that inlines another template file's
content at parse time, as if it were written directly in the template.
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.
filePath to pass through to Parser.
MSBuildProjectDirectory MSBuild property), and a File.ReadAllText
reader to ClassGenerator.
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