SlusserLabs.AnglePlates 1.1.0-ci.34

This is a prerelease version of SlusserLabs.AnglePlates.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package SlusserLabs.AnglePlates --version 1.1.0-ci.34
                    
NuGet\Install-Package SlusserLabs.AnglePlates -Version 1.1.0-ci.34
                    
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="SlusserLabs.AnglePlates" Version="1.1.0-ci.34">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SlusserLabs.AnglePlates" Version="1.1.0-ci.34" />
                    
Directory.Packages.props
<PackageReference Include="SlusserLabs.AnglePlates">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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 SlusserLabs.AnglePlates --version 1.1.0-ci.34
                    
#r "nuget: SlusserLabs.AnglePlates, 1.1.0-ci.34"
                    
#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 SlusserLabs.AnglePlates@1.1.0-ci.34
                    
#: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=SlusserLabs.AnglePlates&version=1.1.0-ci.34&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=SlusserLabs.AnglePlates&version=1.1.0-ci.34&prerelease
                    
Install as a Cake Tool

AnglePlates

AnglePlates is like T4 templates for modern .NET. Give it a template and any model you want to render, and it generates the C# classes at compile time. The compiled templates write straight to a TextWriter or UTF-8 buffer, so there is no runtime package to drag along. That's it! You can make it fancier, but you don't have to.

Templates use C# expressions, loops, and conditions. They compile with your application, work with Native AOT, and need .NET 10 and C# 11 or later.

Quick start

Add the package:

dotnet package add SlusserLabs.AnglePlates

Write a model:

namespace MyApp;

public sealed record GreetingModel
{
    public string Name { get; init; } = default!;
    public string? Message { get; init; }
}

Add Templates/greeting.html. #model is the only required directive:

#model MyApp.GreetingModel

[* A greeting with an optional message. *]

<h1>Hello, [[ model.Name ]]!</h1>

[% if (!string.IsNullOrEmpty(model.Message)) { %]
    <p>[[ model.Message ]]</p>
[% } %]

Build, then render the generated class. In a project whose RootNamespace is MyApp:

using MyApp;
using MyApp.Templates;
using SlusserLabs.AnglePlates;

var model = new GreetingModel { Name = "Ada & Grace", Message = "Welcome!" };
GreetingTextTemplate.Default.Render(model, Console.Out);
string html = GreetingTextTemplate.Default.RenderToString(model);

The name becomes Ada &amp; Grace. C# variables are HTML-encoded; literal text and its line breaks stay unchanged. Comments and C# blocks don't write output, but the line breaks around them do. Trim markers such as [[- model.Name -]] remove adjacent whitespace.

Rendering and options

Each template generates a TextTemplate class for TextWriter and a Utf8Template class for IBufferWriter<byte>. The UTF-8 class also has RenderAsync for PipeWriter, including ASP.NET Core's HttpResponse.BodyWriter. Set #generate Text or #generate Utf8 to generate just one class.

Use Default for a shared instance, or pass options to the constructor:

var email = new GreetingTextTemplate(new TemplateOptions { Encoder = null });
var german = new GreetingTextTemplate(new TemplateOptions
{
    Culture = System.Globalization.CultureInfo.GetCultureInfo("de-DE")
});

TemplateOptions.Encoder starts as HtmlEncoder.Default; null turns encoding off. TemplateOptions.Culture starts as CultureInfo.InvariantCulture. TemplateOptions.NullVariable controls what a null value writes; null writes nothing.

Samples

Both samples are small runnable .NET 10 programs. Each has a README with a run command and expected output:

  • HelloWorld: render a Markdown greeting and numbered task list with conditions and a loop.
  • HelloWorldApi: stream a UTF-8 HTML page with nested models, a child template, and default encoding.

Learn more

Templates are trusted C# source. Only compile templates you'd trust as part of your application. AnglePlates doesn't support T4 syntax, runtime compilation, or IntelliSense inside templates. It doesn't parse embedded C#: blocks end at their matching delimiter.

AI Disclosure

This project was built with the help of Codex 5.6 Sol for code generation. As with any tool I use for coding, I am fully responsible for the end result and only put forward this project with full confidence that I have reviewed every line. Whether a line of code in this project was fully AI generated, AI assisted, or entirely from my own Muppet fingers on the keyboard, it is held to the same expectations.

License

AnglePlates is released under the MIT License.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0-ci.38 0 10/26/2026
1.2.0-ci.37 3 10/24/2026
1.1.0-ci.36 0 10/24/2026
1.1.0-ci.35 0 10/24/2026
1.1.0-ci.34 0 10/24/2026
1.1.0-beta.33.1 0 10/23/2026
1.1.0-beta.1.1 0 10/23/2026