Skip to content

Releases: TriasDev/templify

v1.4.1

07 Jan 20:41

Choose a tag to compare

Processing Warnings System

Collect non-fatal warnings during template processing to help identify issues like missing variables or null collections without failing the entire operation.

Added

  • Processing Warnings System - Collect non-fatal warnings during template processing
    • ProcessingWarning class with warning type, variable name, context, and message
    • Warning types: MissingVariable, MissingLoopCollection, NullLoopCollection, ExpressionFailed
    • Access warnings via ProcessingResult.Warnings and ProcessingResult.HasWarnings
    • Generate Word document warning reports with GetWarningReport() and GetWarningReportBytes()
  • GUI: "Generate Warning Report" button and warning summary display

Improved

  • Test coverage increased to 953 tests

Full Changelog: v1.4.0...v1.4.1

v1.4.0

07 Jan 14:25

Choose a tag to compare

What's New

UpdateFieldsOnOpen Option

Automatically prompt Word to refresh TOC and dynamic fields when documents are opened.

  • UpdateFieldsOnOpenMode.Never - Never prompt (default, backward compatible)
  • UpdateFieldsOnOpenMode.Always - Always prompt to update fields
  • UpdateFieldsOnOpenMode.Auto - Only prompt if document contains dynamic fields (recommended)

Auto mode detects: TOC, PAGE, NUMPAGES, PAGEREF, DATE, TIME, FILENAME, REF, NOTEREF, SECTIONPAGES

This solves stale page numbers when content changes via conditionals/loops.

Usage

var options = new PlaceholderReplacementOptions
{
    UpdateFieldsOnOpen = UpdateFieldsOnOpenMode.Auto
};

var processor = new DocumentTemplateProcessor(options);

Improvements

  • Test coverage increased to 939 tests
  • New test helpers: DocumentBuilder and DocumentVerifier for cleaner TOC testing
  • Updated DocumentFormat.OpenXml to 3.4.1 (performance improvements)

Full Changelog: v1.3.0...v1.4.0

v1.3.0

05 Jan 12:48
ae37420

Choose a tag to compare

Highlights

  • Named Iteration Variable Syntax - Access parent loop variables in nested loops with {{#foreach item in Collection}}
  • ElseIf Support - Multi-branch conditionals with {{#elseif condition}}
  • Text Replacement Lookup Tables - Pre-process text with HtmlEntityPreset for HTML entities
  • .NET 10 Support - Added net10.0 target framework

⚠️ Breaking Change

{{else}} syntax changed to {{#else}} for consistency with other control tags.

Added

  • Text Replacement Lookup Tables - Pre-process text before template processing
    • TextReplacementLookup for custom character/string replacements
    • HtmlEntityPreset for common HTML entities (&, <, >,  , —, –, etc.)
    • GUI support for HTML entity replacement option
  • Named Iteration Variable Syntax - Access parent loop variables in nested loops
    • New syntax: {{#foreach item in CollectionName}}...{{item.Property}}...{{/foreach}}
    • Access parent scope: {{category.Name}} inside {{#foreach product in category.Products}}
  • ElseIf Support for Conditionals - Multi-branch conditional logic with {{#elseif condition}} syntax
    • Chain multiple conditions: {{#if A}}...{{#elseif B}}...{{#elseif C}}...{{#else}}...{{/if}}
    • Conditions evaluated in order - first matching branch wins
  • Newline Character Support - Variable values can now contain \n for line breaks
  • Inline Conditionals - Conditionals within a single paragraph
  • Highlight and Shading Preservation - Per-run placeholder replacement now preserves highlight and shading formatting
  • Typographic Quote Support - Conditional expressions now accept curly/smart quotes ("" '')
  • .NET 10 Support - Added net10.0 target framework

Fixed

  • Conditionals inside loops now evaluate with correct context
  • Loop-scoped variables are now correctly validated in template validation
  • Null values are now treated as valid in template validation
  • Nested paragraphs no longer generated in RepeatingConverter

Improved

  • Test coverage increased to 929 tests
  • Updated NuGet dependencies

Full Changelog: v1.2.0...v1.3.0

v1.2.0 - Text Template Processing

09 Dec 19:21
20ba5ef

Choose a tag to compare

🎉 What's New

Text Template Processing for Emails and Notifications

We're excited to announce TextTemplateProcessor - a new feature that brings Templify's powerful template syntax to plain text processing!

Key Features

  • 📧 Email Generation: Perfect for order confirmations, notifications, and automated emails
  • 📱 SMS Messages: Generate dynamic SMS content
  • 📊 Report Summaries: Create text-based reports with dynamic data
  • 🔄 Same Syntax: Use the exact same template syntax as Word documents

Quick Example

var processor = new TextTemplateProcessor();

string template = @"Dear {{CustomerName}},

Thank you for your order #{{OrderId}}.

{{#if IsVip}}
As a VIP customer, you'll receive free shipping!
{{else}}
Your order will arrive in 3-5 business days.
{{/if}}

Order Details:
{{#foreach Items}}
- {{Name}}: ${{Price}}
{{/foreach}}

Total: ${{Total}}";

var data = new Dictionary<string, object>
{
    ["CustomerName"] = "Alice Smith",
    ["OrderId"] = 12345,
    ["IsVip"] = true,
    ["Items"] = new[]
    {
        new { Name = "Premium Widget", Price = 29.99 },
        new { Name = "Deluxe Gadget", Price = 49.99 }
    },
    ["Total"] = 79.98
};

TextProcessingResult result = processor.ProcessTemplate(template, data);
// Use result.ProcessedText as email body

Supported Features

  • ✅ Placeholder replacement ({{Variable}})
  • ✅ Nested properties ({{Customer.Address.City}})
  • ✅ Conditionals ({{#if}}...{{else}}...{{/if}})
  • ✅ Loops ({{#foreach}}...{{/foreach}})
  • ✅ Loop metadata ({{@index}}, {{@first}}, {{@last}}, {{@count}})
  • ✅ Nested structures (arbitrary depth)
  • ✅ Culture-specific formatting
  • ✅ Configurable missing variable behavior

Documentation

🔧 Technical Details

  • New Classes: TextTemplateProcessor, TextProcessingResult
  • Test Coverage: 23 new tests, maintaining 100% coverage (766 total tests)
  • Performance: Optimized string processing with StringBuilder
  • Backward Compatibility: 100% - no breaking changes

📦 Installation

dotnet add package TriasDev.Templify --version 1.2.0

🙏 Contributors

Thanks to everyone who contributed to this release!


Full Changelog: v1.1.0...v1.2.0

v1.1.0 - Standalone Condition Evaluation API

02 Dec 09:57
1d120da

Choose a tag to compare

What's New in v1.1.0

Standalone Condition Evaluation API

Use Templify's powerful condition evaluation engine without processing Word documents:

using TriasDev.Templify.Conditionals;

var evaluator = new ConditionEvaluator();
var data = new Dictionary<string, object>
{
    ["IsActive"] = true,
    ["Count"] = 5,
    ["Status"] = "Active"
};

// Single evaluation
bool result = evaluator.Evaluate("IsActive and Count > 0", data);

// Batch evaluation (more efficient for multiple conditions)
var context = evaluator.CreateConditionContext(data);
bool r1 = context.Evaluate("IsActive");
bool r2 = context.Evaluate("Count > 3");
bool r3 = context.Evaluate("Status = \"Active\"");

New Features

  • IConditionEvaluator - Interface for evaluating conditional expressions against data
  • ConditionEvaluator - Implementation with full operator support (=, !=, >, <, >=, <=, and, or, not)
  • IConditionContext - Interface for efficient batch evaluation of multiple expressions
  • ConditionContext - Reusable evaluation context
  • Async methods with CancellationToken support
  • Thread-safe implementation

Documentation

Improvements

  • Code quality enforcement via .editorconfig rules
  • Test coverage increased to 743 tests

Full Changelog: v1.0.0...v1.1.0

Templify v1.0.0 - Initial Release

20 Nov 20:16

Choose a tag to compare

Initial public release of Templify - a high-performance Word document templating engine for .NET.

Highlights

  • Simple placeholder replacement with {{variableName}} syntax
  • Conditional blocks with if/else logic and boolean operators
  • Loop support for collections and table rows with nested loop capability
  • Markdown formatting in variable values (**bold**, *italic*, ~~strikethrough~~)
  • Format specifiers for dates, numbers, and booleans
  • Multi-framework support (.NET 6, 8, 9)
  • 100% test coverage with 109+ tests
  • Zero dependencies (only OpenXML SDK)
  • Cross-platform (Windows, Linux, macOS)

Tools Included

  • TriasDev.Templify - Core library
  • TriasDev.Templify.Converter - CLI tool for migrating from OpenXMLTemplates
  • TriasDev.Templify.Gui - Cross-platform GUI application
  • TriasDev.Templify.Demo - Example console application

Performance

  • Processes 1,000 placeholders in ~50ms
  • Handles 100 loops in ~150ms
  • Evaluates 500 conditionals in ~30ms
  • Complex 50-page documents in ~500ms

Documentation

Installation

dotnet add package TriasDev.Templify

See the full changelog for detailed feature list.