HatTrick.Text.Templating
3.0.0
Prefix Reserved
dotnet add package HatTrick.Text.Templating --version 3.0.0
NuGet\Install-Package HatTrick.Text.Templating -Version 3.0.0
<PackageReference Include="HatTrick.Text.Templating" Version="3.0.0" />
<PackageVersion Include="HatTrick.Text.Templating" Version="3.0.0" />
<PackageReference Include="HatTrick.Text.Templating" />
paket add HatTrick.Text.Templating --version 3.0.0
#r "nuget: HatTrick.Text.Templating, 3.0.0"
#:package HatTrick.Text.Templating@3.0.0
#addin nuget:?package=HatTrick.Text.Templating&version=3.0.0
#tool nuget:?package=HatTrick.Text.Templating&version=3.0.0
HatTrick.Text.Templating
A small, allocation-conscious text templating engine for .NET.
Full documentation | hattricklabs.com
Installation
The package targets net9.0.
dotnet add package HatTrick.Text.Templating
using HatTrick.Text.Templating;
Quick Start
var fullName = new { FirstName = "John", LastName = "Doe" };
string template = "Hello {FirstName} {LastName}, this is just a test.";
TemplateEngine ngin = new TemplateEngine(template);
string result = ngin.Merge(fullName);
//result = Hello John Doe, this is just a test.
Features
- Simple
{tag}and compound bind-expression ({Name.First}) replacement - Conditional blocks (
{#if}) and iteration blocks ({#each}) with falsy-value rules - Scope shifting (
{#with}) and backward scope-chain walks (..\) - Local variable declaration, reassignment, and block-scoped lifetime (
{?var:},{?:},{:name}) - Partial template injection (
{>tag}) for composable sub-templates - Lambda expression calls for formatting, sorting, joining, and custom logic
- Whitespace control (
-/+trim markers) and a debug tag ({@}) for trace-based troubleshooting - A
MergeExceptionwith line/column/char-index context for precise error location
See the full documentation for all of the above in depth.
License
Apache-2.0 — see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- HatTrick.Reflection (>= 3.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on HatTrick.Text.Templating:
| Package | Downloads |
|---|---|
|
HatTrick.CommandLine
HatTrick Labs command line interface tools. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Breaking: numeric literals in templates no longer require or support a type-suffix postfix.
Allocation-reduction pass across the parser/merge pipeline: char-buffer based tag building, cached compiled lambda invokers (no more dynamic invoke), and hot-path optimizations for simple-tag binding.
Added TemplateStackDepthException with richer MergeException context (start-block tag tracking) for clearer error locations.
Fixed: lambda registration could throw before the intended duplicate-key exception.
Fixed: debug tag misidentified when adjacent to whitespace trim markers (#62).
Lambda argument parsing now accepts null for nullable parameter types.
Upgraded target framework to net9.0.