The project provides PHP's Twig library for .NET.
The Twig library is developed at https://github.com/twigphp/Twig/
<PackageReference Include="Twig.AspNetCore" Version="3.0.3" />
or
dotnet add package Twig.AspNetCore -v 3.0.3
@{
ViewData["Title"] = "My Twig Page";
}
@Html.Twig("/path/to/templates", "index.html", new { name = "John Doe", });
- Twig.Twig: contains the Twig library.
- Twig.AspNetCore: provides helpers for Razor pages.
- Twig.AspNetCore.Demo: a sample ASP.NET Core website rendering a twig template
The unmodified PHP code is compiled to .NET assembly using PeachPie PHP Compiler. Resulting library can be seamlessly referenced by other .NET projects (C#, VB.NET, F#), used for rendering Twig e.g. within ASP.NET Core pages.