ASTTemplateParser 4.0.0
dotnet add package ASTTemplateParser --version 4.0.0
NuGet\Install-Package ASTTemplateParser -Version 4.0.0
<PackageReference Include="ASTTemplateParser" Version="4.0.0" />
<PackageVersion Include="ASTTemplateParser" Version="4.0.0" />
<PackageReference Include="ASTTemplateParser" />
paket add ASTTemplateParser --version 4.0.0
#r "nuget: ASTTemplateParser, 4.0.0"
#:package ASTTemplateParser@4.0.0
#addin nuget:?package=ASTTemplateParser&version=4.0.0
#tool nuget:?package=ASTTemplateParser&version=4.0.0
AST Template Parser
A high-performance, security-hardened template parser for .NET Framework 4.8 with HTML-like syntax.
✨ Features
- 🚀 High Performance - 7,000+ renders/second, compiled property accessors
- 🔒 Enterprise Security - XSS, SQL injection, code injection protection
- 🧩 Component System - Reusable components with parameters and slots
- 📐 Layout System - Master layouts with sections
- 🎯 ASP.NET MVC 5 - Full integration with controllers and HtmlHelpers
- 📝 HTML-like Syntax - No @ directives, pure HTML tags
📦 Installation
Install-Package ASTTemplateParser
Or via .NET CLI:
dotnet add package ASTTemplateParser
🚀 Quick Start
using ASTTemplateParser;
var engine = new TemplateEngine();
engine.SetVariable("UserName", "John");
engine.SetVariable("Products", productList);
var template = @"
<Element template=""page"">
<h1>Welcome, {{UserName}}!</h1>
<ForEach var=""p"" in=""Products"">
<p>{{p.Name}} - ${{p.Price}}</p>
</ForEach>
</Element>";
string html = engine.Render(template);
📖 Syntax Overview
Variables
{{UserName}}
{{Order.Customer.Name}}
Conditionals
<If condition="IsLoggedIn">
<p>Welcome back!</p>
<ElseIf condition="IsGuest">
<p>Hello Guest!</p>
<Else>
<p>Please login</p>
</If>
Loops
<ForEach var="item" in="Items">
<li>{{item.Name}}</li>
</ForEach>
Components
<Include component="element/button">
<Param name="text" value="Click Me" />
<Param name="type" value="primary" />
</Include>
🔧 ASP.NET MVC 5
// Global.asax
MvcIntegration.Initialize();
// Controller
public class HomeController : TemplateController
{
public ActionResult Index()
{
return Template(new { Title = "Home" });
}
}
// Razor View
@Html.Button("Click", "/action", "primary")
@Html.RenderComponent("block/card", new { title = "Card" })
🔒 Security
- ✅ HTML encoding by default (XSS protection)
- ✅ Expression validation (code injection protection)
- ✅ Path traversal prevention
- ✅ Loop iteration limits (DoS protection)
- ✅ Blocked sensitive properties (Password, Token, etc.)
📊 Performance
| Template Size | Throughput |
|---|---|
| Small (1KB) | ~7,000 ops/sec |
| Medium (4KB) | ~1,600 ops/sec |
| Large (8KB) | ~800 ops/sec |
📄 License
MIT License - See LICENSE for details.
📚 Documentation
See DOCUMENTATION.md for complete API reference.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- Microsoft.AspNet.Mvc (>= 5.3.0)
- NCalcSync (>= 5.11.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.1.3 | 25 | 3/11/2026 |
| 2.1.2 | 37 | 3/10/2026 |
| 2.1.1 | 98 | 3/2/2026 |
| 2.1.0 | 83 | 2/28/2026 |
| 2.0.9 | 86 | 2/28/2026 |
| 2.0.8 | 101 | 2/15/2026 |
| 2.0.7 | 99 | 2/10/2026 |
| 2.0.6 | 110 | 2/10/2026 |
| 2.0.5 | 92 | 2/9/2026 |
| 2.0.4 | 94 | 2/9/2026 |
| 2.0.3 | 96 | 1/21/2026 |
| 2.0.2 | 91 | 1/20/2026 |
| 2.0.0 | 102 | 1/20/2026 |
| 1.0.45 | 106 | 1/19/2026 |
| 1.0.43 | 96 | 1/19/2026 |
| 1.0.42 | 92 | 1/19/2026 |
| 1.0.41 | 94 | 1/19/2026 |
| 1.0.40 | 97 | 1/19/2026 |
| 1.0.39 | 105 | 1/17/2026 |
v4.0.0 - Major Release
- Component System with Include/Param tags
- Layout System with RenderSection/RenderBody
- Slot System for component content injection
- ASP.NET MVC 5 Integration (TemplateController, HtmlHelper extensions)
- Enterprise-grade Security (XSS, SQL injection, code injection protection)
- High Performance (7,000+ ops/sec for small templates)
- HTML Comment handling (prevents recursion in component docs)