Soenneker.Utils.Template
4.0.390
Prefix Reserved
dotnet add package Soenneker.Utils.Template --version 4.0.390
NuGet\Install-Package Soenneker.Utils.Template -Version 4.0.390
<PackageReference Include="Soenneker.Utils.Template" Version="4.0.390" />
<PackageVersion Include="Soenneker.Utils.Template" Version="4.0.390" />
<PackageReference Include="Soenneker.Utils.Template" />
paket add Soenneker.Utils.Template --version 4.0.390
#r "nuget: Soenneker.Utils.Template, 4.0.390"
#:package Soenneker.Utils.Template@4.0.390
#addin nuget:?package=Soenneker.Utils.Template&version=4.0.390
#tool nuget:?package=Soenneker.Utils.Template&version=4.0.390
Soenneker.Utils.Template
Asynchronous Scriban rendering for file-based templates, with token globals, composed content, and timestamp-based parsing cache.
Installation
dotnet add package Soenneker.Utils.Template
Registration
using Soenneker.Utils.Template.Registrars;
services.AddTemplateUtilAsSingleton();
The singleton registration shares parsed templates across the application. Use AddTemplateUtilAsScoped() when the cache should live only for a dependency-injection scope.
Render a template
using Soenneker.Utils.Template.Abstract;
var tokens = new Dictionary<string, object>
{
["Name"] = "Ada",
["AccountUrl"] = "https://example.test/account"
};
string result = await templateUtil.Render(
"Templates/welcome.scriban",
tokens,
cancellationToken: cancellationToken);
Template variables use the dictionary keys directly:
Hello {{ Name }}. Manage your account at {{ AccountUrl }}.
The supplied dictionary is read while globals are constructed and is not mutated. Scriban performs the value formatting; this utility does not HTML-encode output automatically.
Compose content into a layout
RenderWithContent renders the content file first using the supplied tokens, then exposes the resulting string to the main template under Body by default:
string page = await templateUtil.RenderWithContent(
templateFilePath: "Templates/layout.scriban",
tokens: tokens,
contentFilePath: "Templates/welcome-content.scriban",
contentPlaceholderKey: "Body",
cancellationToken: cancellationToken);
<main>{{ Body }}</main>
The original token dictionary is not changed. If it already contains the placeholder key, the rendered content is the value used by the main template.
Raw partial values
The optional partials dictionary adds each entry as a global string. It does not parse or register Scriban include files. A value can be emitted with {{ Footer }}, but Scriban syntax inside that string is not rendered a second time.
Caching and failures
Parsed templates are cached by their full file path and last-modified timestamp. A changed timestamp causes the file to be read and parsed again. With scoped registration, each scope has its own cache; with singleton registration, the cache is application-wide.
Missing files, Scriban parse errors, rendering failures, and cancellation are propagated to the caller. Rendering failures from the main template are also logged. The cancellation token applies to file access and Scriban execution.
| 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. |
-
net10.0
- Scriban (>= 7.2.7)
- Soenneker.Utils.File (>= 4.0.2248)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Soenneker.Utils.Template:
| Package | Downloads |
|---|---|
|
Soenneker.Email.Sender
A high-level utility responsible for orchestrating the creation and delivery of templated email messages |
|
|
Soenneker.Email.Senders.Resend
A high-level utility responsible for orchestrating the creation and delivery of templated email messages using Resend |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.390 | 0 | 9/4/2026 |
| 4.0.389 | 54 | 9/4/2026 |
| 4.0.387 | 78 | 9/2/2026 |
| 4.0.386 | 125 | 9/1/2026 |
| 4.0.385 | 111 | 8/31/2026 |
| 4.0.384 | 147 | 8/31/2026 |
| 4.0.383 | 99 | 8/31/2026 |
| 4.0.382 | 72 | 8/31/2026 |
| 4.0.381 | 96 | 8/30/2026 |
| 4.0.380 | 79 | 8/30/2026 |
| 4.0.379 | 133 | 8/30/2026 |
| 4.0.378 | 118 | 8/30/2026 |
| 4.0.377 | 90 | 8/30/2026 |
| 4.0.376 | 113 | 8/29/2026 |
| 4.0.375 | 87 | 8/29/2026 |
| 4.0.374 | 82 | 8/29/2026 |
| 4.0.373 | 83 | 8/29/2026 |
| 4.0.372 | 382 | 8/26/2026 |
| 4.0.371 | 142 | 8/26/2026 |
| 4.0.370 | 182 | 8/22/2026 |
Updated Soenneker.Utils.File to 4.0.2248