jakubmisek / dotnet-twig

Twig template engine for .NET

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Twig for .NET

The project provides PHP's Twig library for .NET.

The Twig library is developed at https://github.com/twigphp/Twig/

Basic usage

Add package reference to your Web Application

<PackageReference Include="Twig.AspNetCore" Version="3.0.3" />

or

dotnet add package Twig.AspNetCore -v 3.0.3

Render Twig template in a razor page

@{
    ViewData["Title"] = "My Twig Page";
}

@Html.Twig("/path/to/templates", "index.html", new { name = "John Doe", });

Repository structure

  • 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

How it works

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.

About

Twig template engine for .NET

License:Apache License 2.0


Languages

Language:PHP 98.3%Language:C# 1.2%Language:Shell 0.4%Language:HTML 0.1%