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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Utils.Template" Version="4.0.390" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Utils.Template" Version="4.0.390" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Utils.Template" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Utils.Template --version 4.0.390
                    
#r "nuget: Soenneker.Utils.Template, 4.0.390"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Utils.Template@4.0.390
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Utils.Template&version=4.0.390
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.Template&version=4.0.390
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed

Updated Soenneker.Utils.File to 4.0.2248