Hyperbee.Templating
3.5.1
dotnet add package Hyperbee.Templating --version 3.5.1
NuGet\Install-Package Hyperbee.Templating -Version 3.5.1
<PackageReference Include="Hyperbee.Templating" Version="3.5.1" />
<PackageVersion Include="Hyperbee.Templating" Version="3.5.1" />
<PackageReference Include="Hyperbee.Templating" />
paket add Hyperbee.Templating --version 3.5.1
#r "nuget: Hyperbee.Templating, 3.5.1"
#:package Hyperbee.Templating@3.5.1
#addin nuget:?package=Hyperbee.Templating&version=3.5.1
#tool nuget:?package=Hyperbee.Templating&version=3.5.1
Hyperbee Templating
Hyperbee Templating is a lightweight templating and variable substitution syntax engine. The library supports value replacements, code expressions, token nesting, in-line definitions, conditional flow, and looping. It is designed to be lightweight and fast.
Features
- Variable substitution syntax engine
- Value replacements
- Expression replacements
- Token nesting
- Conditional tokens
- Conditional flow
- Iterators
- User-defined methods
Getting Started
To get started with Hyperbee.Templating, refer to the documentation for detailed instructions and examples.
Install via NuGet:
dotnet add package Hyperbee.Templating
Target frameworks
| Package | Targets | Oldest consumer |
|---|---|---|
| Hyperbee.Templating | net11.0;net10.0;netstandard2.1 |
net8.0 |
| Hyperbee.Templating.Provider.XS | net11.0;net10.0;netstandard2.1 |
net8.0 |
net8.0 and net9.0 both reached end of support on 2026-11-10 and are no longer built
directly. Both packages add netstandard2.1 in their place, so a net8.0 or net9.0
project resolves that asset and keeps working.
The netstandard2.1 assets differ from the net10.0 and net11.0 assets in two ways:
Hyperbee.Templatingloads compiled token expressions withAssembly.Loadinstead of a collectibleAssemblyLoadContext, whichnetstandard2.1does not include.Hyperbee.Templating.Provider.XSruns on thenetstandard2.1asset ofHyperbee.XS, which leaves out thepackagedirective. Every other XS extension is available.
Building this repository requires the .NET 11 SDK; the older targeting packs come from NuGet, so one SDK covers every target.
Basic Usage
Variable Substitution
You can use the TemplateParser to perform variable substitutions.
var template = "hello {{name}}.";
var result = Template.Render(template, new()
{
Variables =
{
["name"] = "me"
}
});
Console.WriteLine(result); // Output: hello me.
Expression Substitution
var template = "hello {{x => x.name.ToUpper()}}.";
var result = Template.Render(template, new()
{
Variables =
{
["name"] = "me"
}
});
Console.WriteLine(result); // Output: hello ME.
Token Nesting
Token values can contain other tokens.
var template = "hello {{fullname}}.";
var result = Template.Render(template, new()
{
Variables =
{
["fullname"] = "{{first}} {{last}}",
["first"] = "Hari",
["last"] = "Seldon"
}
});
Console.WriteLine(result); // Output: hello Hari Seldon.
Conditional Tokens
You can use conditional tokens to control the flow based on conditions.
var template = "{{if condition}}hello {{name}}.{{/if}}";
var result = Template.Render(template, new()
{
Variables =
{
["condition"] = "true",
["name"] = "me"
}
});
Console.WriteLine(result); // Output: hello me.
var template = "hello {{if condition}}{{name1}}{{else}}{{name2}}{{/if}}.";
var result = Template.Render(template, new()
{
Variables =
{
["condition"] = "false",
["name1"] = "me",
["name2"] = "you",
}
});
Console.WriteLine(result); // Output: hello you.
While Statement
You can use a while statement to repeat a block of text while a condition is true.
var template = "{{while x => x.counter<int> < 3}}{{counter}}{{counter:{{x => x.counter<int> + 1}}}}{{/while}}";
var result = Template.Render(template, new()
{
Variables =
{
["counter"] = "0"
}
});
Console.WriteLine(result); // Output: 012.
Each Statement
var template = "{{each n:x => x.list.Split( \",\" )}}World {{n}},{{/each}}";
var result = Template.Render(template, new()
{
Variables =
{
["list"] = "John,James,Sarah"
}
});
Console.WriteLine(result); // hello World John,World James,World Sarah,.
var template = "{{each n:x => x.Where( t => Regex.IsMatch( t.Key, \"people*\" ) ).Select( t => t.Value )}}hello {{n}}. {{/each}}";
var result = Template.Render(template, new()
{
Variables =
{
["people[0]"] = "John",
["people[1]"] = "Jane",
["people[2]"] = "Doe"
}
});
Console.WriteLine(result); // hello John. hello Jane. hello Doe.
Methods
You can invoke methods within token expressions.
var options = new TemplateOptions()
.AddVariable("name", "me")
.AddMethod("ToUpper").Expression<string,string>( value => value.ToUpper() );
var template = "hello {{x => x.ToUpper( x.name )}}.";
var result = Template.Render(template, options);
Console.WriteLine(result); // Output: hello ME.
Credits
Special thanks to:
- Just The Docs for the documentation theme.
Contributing
We welcome contributions! Please see our Contributing Guide for more details.
Status
| Branch | Action |
|---|---|
main |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Hyperbee.Resources (>= 2.2.3)
- Microsoft.CodeAnalysis.CSharp (>= 5.12.0)
- Microsoft.CSharp (>= 4.7.0)
-
net10.0
- Hyperbee.Resources (>= 2.2.3)
- Microsoft.CodeAnalysis.CSharp (>= 5.12.0)
-
net11.0
- Hyperbee.Resources (>= 2.2.3)
- Microsoft.CodeAnalysis.CSharp (>= 5.12.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Hyperbee.Templating:
| Package | Downloads |
|---|---|
|
Hyperbee.Templating.Provider.XS
Adds an ITokenExpressionProvider powder by Hyperbee.XS |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.5.1 | 56 | 11/28/2026 |
| 3.4.2 | 186 | 8/31/2026 |
| 3.4.1 | 313 | 1/26/2026 |
| 3.4.1-alpha-g9cc415e398 | 173 | 1/26/2026 |
| 3.3.4 | 267 | 12/22/2025 |
| 3.2.0 | 269 | 5/9/2025 |
| 3.1.0 | 267 | 5/1/2025 |
| 3.0.2 | 323 | 4/14/2025 |
| 3.0.2-develop.250414130051 | 260 | 4/14/2025 |
| 3.0.1 | 293 | 2/17/2025 |
| 3.0.1-develop.250217125033 | 177 | 2/17/2025 |
| 3.0.0 | 240 | 12/19/2024 |
| 3.0.0-develop.241219164731 | 162 | 12/19/2024 |
| 2.0.0 | 351 | 8/23/2024 |
| 1.0.3 | 282 | 8/13/2024 |
| 1.0.2 | 257 | 8/13/2024 |
| 1.0.1 | 300 | 4/11/2024 |
| 1.0.0 | 286 | 4/9/2024 |