TriasDev.Templify.Builder
0.1.0
Prefix Reserved
dotnet add package TriasDev.Templify.Builder --version 0.1.0
NuGet\Install-Package TriasDev.Templify.Builder -Version 0.1.0
<PackageReference Include="TriasDev.Templify.Builder" Version="0.1.0" />
<PackageVersion Include="TriasDev.Templify.Builder" Version="0.1.0" />
<PackageReference Include="TriasDev.Templify.Builder" />
paket add TriasDev.Templify.Builder --version 0.1.0
#r "nuget: TriasDev.Templify.Builder, 0.1.0"
#:package TriasDev.Templify.Builder@0.1.0
#addin nuget:?package=TriasDev.Templify.Builder&version=0.1.0
#tool nuget:?package=TriasDev.Templify.Builder&version=0.1.0
TriasDev.Templify.Builder
Preview (0.x), experimental. The API may change in any release until the first stable one. Using it reports diagnostic
TPLB001; opt in with<NoWarn>$(NoWarn);TPLB001</NoWarn>in your project.
Describe Templify templates in C# and generate them at runtime as Word (.docx) or OpenDocument Text (.odt)
files. TriasDev.Templify then fills the generated templates with
data.
- One definition, every format and language. Named styles from your theme, texts from a catalog, DOCX and ODT from the same code.
- Invalid template syntax cannot be written. Markers, conditions, loops and value formats come from the API, in the shapes the engine supports.
- A data contract and an identity stamp. Every build lists the data it needs, and an uploaded, hand-edited copy can be checked against it.
using System.Globalization;
using TriasDev.Templify.Builder;
using TriasDev.Templify.Core;
public sealed class InvoiceTemplate(BrandTheme theme) : ITemplateDefinition
{
private static readonly ParagraphStyleKey Title = new("Title1", "Invoice Title");
private static readonly ParagraphStyleKey Body = new("Body", "Body Copy");
private static readonly CharacterStyleKey Strong = new("Strong", "Strong Text");
public TemplateIdentity Identity { get; } = new("invoice", 1);
public void Compose(TemplateComposer template)
{
TemplateTexts t = template.Texts;
TemplatePath order = template.Data["order"];
template.Styles(StyleSheet.Create(s =>
{
s.Defaults(d => d.Font(theme.BodyFont).Size(10.5.Pt()).Color(theme.Ink));
s.Paragraph(Body, p => p.SpaceAfter(6.Pt()));
s.Paragraph(Title, p => p.BasedOn(Body).Size(18.Pt()).Color(theme.Accent).OutlineLevel(1));
s.Character(Strong, c => c.Bold());
}));
template.Properties(p => p.Title(t["invoice"]));
template.Content(c =>
{
c.Paragraph(Title, x => { x.Text(t["invoice"] + " "); x.Value(order["number"]); });
c.ForEach(order["lines"], "line", (line, b) => b.Paragraph(Body, x =>
{
x.Value(line["description"]);
x.Tab();
x.Value(Strong, line["amount"], ValueFormat.Currency);
}));
c.Switch(order["status"], s =>
{
s.Case("paid", b => b.Paragraph(Body, t["paid"]));
s.Default(b => b.Paragraph(Body, t["open"]));
});
});
}
}
GeneratedTemplate template = TemplateBuilder.Build(
new InvoiceTemplate(theme),
new TemplateBuildOptions { Format = TemplateFormat.Odt, Language = CultureInfo.GetCultureInfo("de-DE"), Texts = texts });
// Hand it to a user as a download (template.OpenRead(), template.MediaType, "invoice" + template.FileExtension)
// or fill it right away:
using MemoryStream output = new MemoryStream();
new TemplateProcessor().ProcessTemplate(template.OpenRead(), output, json);
// Later, check a copy the user edited and uploaded against the current data (Ok, Warning or Broken):
TemplateCheckResult check = TemplateInspector.Check(upload, new TemplateCheckOptions { Data = DataCatalog.From<InvoiceData>() });
The output is deterministic: the same definition and options produce the same bytes on the same runtime and operating
system family, so GeneratedTemplate.ContentHash can serve as a cache key. Requires TriasDev.Templify 1.11.0 or later.
The documentation page explains the
concepts, the support matrix and the known limits. The sample
samples/TriasDev.Templify.Builder.Sample
uses every construct. Verify your definitions in CI with
TriasDev.Templify.Builder.Testing:
[Fact]
public void InvoiceTemplate_IsValid() => TemplateVerifier.VerifyAll(
() => new InvoiceTemplate(theme),
new TemplateVerificationOptions { Languages = [de, en], Texts = _ => texts, SampleData = [sampleJson] });
The design and the roadmap are in the design spec and in epic #261.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. net11.0 is compatible. |
-
net10.0
- DocumentFormat.OpenXml (>= 3.5.1)
- TriasDev.Templify (>= 1.11.0)
-
net11.0
- DocumentFormat.OpenXml (>= 3.5.1)
- TriasDev.Templify (>= 1.11.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on TriasDev.Templify.Builder:
| Package | Downloads |
|---|---|
|
TriasDev.Templify.Builder.Testing
Test kit for TriasDev.Templify.Builder: verify template definitions in your CI (build, validate, fill with sample data and the contract's witness, DOCX schema and ODT package checks, byte determinism, contract parity across languages and formats), snapshot dumps for golden tests and a LibreOffice conversion helper. Test-framework neutral. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 49 | 12/2/2026 |