Fluid parses and renders Shopify Liquid templates in .NET with allow-listed models and configurable limits. It supports async filters, custom tags, view engines, and optional source generators.
Overview
Fluid is an open-source .NET template engine implementing the Liquid language popularized by Shopify. It targets scenarios where templates must be safe for non-developers: only properties exposed on an allow-listed model are readable, and rendering can be bounded with recursion, step, output, and collection limits.
The parser builds a concrete syntax tree for caching and analysis, renders with few allocations and no regular-expression parsing, and offers async filters and file providers for I/O-heavy templates. Developers can register custom filters, tags, blocks, and operators using the extensible Parlot-based grammar, and integrate HTML or JSON encoders at render time.
Models can be plain CLR objects, dictionaries, System.Text.Json nodes, or custom FluidValue converters, with optional camelCase name matching. TemplateOptions and parsers are thread-safe and intended to be shared, while each render uses its own TemplateContext. Documentation covers security guidance for user-supplied templates, culture and time-zone handling aligned with Ruby Liquid semantics, and optional Shopify-compatible money and color filters.
Companion packages add source generators for NativeAOT-friendly model accessors and compile-time conversion of shipped .liquid files into C# classes. ASP.NET Core integrations provide Liquid views for MVC or Minimal APIs, and a CLI plus browser playground help try templates outside an application.
Key features
- Shopify Liquid syntax compatibility
- Allow-listed secure models
- Async filters and file providers
- Custom tags, blocks, operators
- Template AST parse and cache
- Optional compiled .liquid generator
- ASP.NET Core view engine
- Configurable render limits
Use cases
- User-editable email or report templates
- Shopify-style views in .NET apps
- Sanitized CMS theme rendering
- NativeAOT-friendly templating
- Minimal API Liquid responses