Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,19 @@ The library uses a **visitor pattern** for processing Word documents, enabling:
{{/foreach}}
```

**Named iteration variable syntax** (for accessing parent scope in nested loops):
```
{{#foreach item in CollectionName}}
{{item.PropertyName}}
{{/foreach}}

{{#foreach category in Categories}}
{{#foreach product in category.Products}}
{{category.Name}}: {{product.Name}} ← Access parent loop variable
{{/foreach}}
{{/foreach}}
```

**Loop metadata:** `{{@index}}`, `{{@first}}`, `{{@last}}`, `{{@count}}`

### Markdown Syntax
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Templify is a focused .NET library built on the OpenXML SDK that enables dynamic
- ✨ Markdown formatting in variable values: `**bold**`, `*italic*`, `~~strikethrough~~`
- ↩️ Line breaks in variable values: `"Line 1\nLine 2"` renders as separate lines
- 🔀 Conditional blocks: `{{#if}}...{{#elseif}}...{{#else}}...{{/if}}`
- 🔁 Loops and iterations: `{{#foreach collection}}...{{/foreach}}`
- 🔁 Loops and iterations: `{{#foreach collection}}...{{/foreach}}` or `{{#foreach item in collection}}...{{/foreach}}`
- 🌳 Nested data structures with dot notation and array indexing
- 🎨 Automatic formatting preservation (bold, italic, fonts, colors)
- 📊 Full table support including row loops
Expand Down
2 changes: 1 addition & 1 deletion TriasDev.Templify.Tests/ConditionalEvaluatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ public void Evaluate_DeepNestedPath_InLoopContext_WhenItemHasSamePath_ReturnsTru

object loopContext = Activator.CreateInstance(
loopContextType,
new object[] { firstItem, 0, 1, "data.assets.items", null! })!;
new object[] { firstItem, 0, 1, "data.assets.items", null!, null! })!;

IEvaluationContext loopEvalContext = (IEvaluationContext)Activator.CreateInstance(
loopEvalContextType,
Expand Down
Loading