Open source, MIT licensed
Liquid templates for .NET. Fast, safe, yours.
Fluid parses and renders Liquid, the template language of Shopify, with few allocations. Templates only read the data you allow, so your users can write them, and every filter, tag and operator can be extended.
dotnet add package Fluid.Core
<ul>
{% for product in products %}
<li>{{ product.name | upcase }}
{{ product.price | money }}
</li>
{% endfor %}
</ul>
<ul>
<li>APPLE $329.00</li>
<li>ORANGE $25.00</li>
<li>BANANA $99.00</li>
</ul>
Features
Everything Liquid, and what .NET applications need
- 01
Shopify compatible
Reads templates like Shopify Liquid, verified with the Golden Liquid test suite and against Shopify's own engine.
Liquid syntax - 02
Fast, few allocations
A hand-written parser, no regular expressions, and a synchronous fast path for async rendering.
Benchmarks - 03
Secure by design
Templates read an allow-listed model, and limits bound recursion, steps, output size and collections.
Security - 04
Async everything
Filters, member accessors and file providers can be asynchronous, and renderings can be cancelled.
Parsing and rendering - 05
Your own grammar
Register tags, blocks, operators and functions, with any parser built from Parlot combinators.
Extending the grammar - 06
Any .NET model
POCOs, dictionaries,
Models and valuesJsonNodeand custom values, with value converters and naming policies. - 07
Source generators
Read models without reflection for NativeAOT, or compile
Compiled templates.liquidfiles into C# at build time. - 08
ASP.NET Core views
Liquid views with layouts, sections and
View engines_ViewStartfiles, for MVC or Minimal APIs.
Three lines
Parse once, render many times
A parser and the options are created once and shared by the whole application. Parsed templates are thread-safe and can be cached, and each rendering gets its own context.
Getting startedvar parser = new FluidParser();
var template = parser.Parse("Hello {{ name | capitalize }}!");
var context = new TemplateContext(new { name = "world" });
Console.WriteLine(await template.RenderAsync(context));
// Hello World!
Benchmarks
Faster than the other .NET Liquid engines
Rendering a page of 100 products with filters and properties, with BenchmarkDotNet.
Write a template now.
The playground runs Fluid in your browser with WebAssembly. Change the template, the model and the options, and share a link to the result.
Open the playground