Relatude.DB.Scriban 1.1.11.42-alpha

This is a prerelease version of Relatude.DB.Scriban.
dotnet add package Relatude.DB.Scriban --version 1.1.11.42-alpha
                    
NuGet\Install-Package Relatude.DB.Scriban -Version 1.1.11.42-alpha
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Relatude.DB.Scriban" Version="1.1.11.42-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Relatude.DB.Scriban" Version="1.1.11.42-alpha" />
                    
Directory.Packages.props
<PackageReference Include="Relatude.DB.Scriban" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Relatude.DB.Scriban --version 1.1.11.42-alpha
                    
#r "nuget: Relatude.DB.Scriban, 1.1.11.42-alpha"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Relatude.DB.Scriban@1.1.11.42-alpha
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Relatude.DB.Scriban&version=1.1.11.42-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Relatude.DB.Scriban&version=1.1.11.42-alpha&prerelease
                    
Install as a Cake Tool

Relatude.DB.Scriban

Scriban templates for Relatude.CMS: pages, emails, feeds and any other text, kept as text files in the database's file library and evaluated at runtime. Change a template and the next request shows it, with no build.

Using an AI coding agent? This package ships a Claude Code skill (relatude-scriban) with the same guidance below. It builds on the relatude-cms skill.

Setup

using Relatude.DB.CMS.Templates;
using Relatude.DB.Scriban;

builder.AddRelatudeCMS()
    .AddApi()                                   // the CMS interface and its Templates blade
    .AddModule<ScribanModule>();

AddRelatudeCMS() brings the templates module; this package brings the engine of .sbn-html (HTML, what expressions write is escaped) and .sbn (plain text) files, and their kind in the file library, IScribanFile (a text file). A page renders with a template through a page template of the kind IFileTemplate, whose File is the template file, chosen for a page or bound to its type (templates.bind).

Where templates are kept

In the site's design library, a library of the file library (Design unless TemplatesOptions.Library names another), as text files named by their path from its top. include, layout and asset.url find files from the top of the library the template is in. A new database gets its first files from the site's project with TemplateSeed, which makes what is missing and never changes a file the library has:

Design/                                    (embedded: <EmbeddedResource Include="Design\**" LogicalName="design/%(RecursiveDir)%(Filename)%(Extension)" />)
  layouts/site.sbn-html
  partials/menu.sbn-html
  pages/article.sbn-html
  emails/order-confirmation.sbn
  css/site.css
await TemplateSeed.EnsureAsync(db, TemplateSeed.FromResources(typeof(Program).Assembly, "design"), new LibraryFileKinds([ScribanModule.Kind]));

After that they are the database's: edited in the CMS (the file library opens a text file in its code editor), by an AI agent over MCP, or with templates.save.

A template

+++
api = 1
model = "IArticle"
layout = "layouts/site"
+++
{{ capture head }}<meta name="description" content="{{ model.MetaDescription }}">{{ end }}
<article>
  <h1>{{ model.Title ?? model.Name }}</h1>
  {{ if model.Picture }}<img src="{{ model.Picture | image.url { width: 1200, mode: "fill" } }}" alt="{{ model.Picture.title }}">{{ end }}
  {{ model.Body }}
  <ul>{{ for child in (content.children model) }}<li><a href="{{ child.url }}">{{ child.Name }}</a></li>{{ end }}</ul>
  {{ include "partials/related" }}
</article>

The layout writes {{ body }} and sees the page's variables (head above). Front matter keys: api (1), model, layout, content_type, description.

  • Names: data by its datamodel name (model.MetaTitle), the engine's own in lower case (model.url, content.children). A node's property wins over an engine member of the same name.
  • Read as the visitor: pages, relations, references and lists hold what the visitor may read, in their culture.
  • Escaping: in .sbn-html every expression is escaped; HTML properties, body, includes, captures and raw are not.
  • Empty is null: empty text, empty HTML and a missing file, so ?? and if read as meant.
  • Parentheses around a function call in a for: for child in (content.children model).
  • No .NET object is reachable from a template; only the engine's objects (and the parts of a date).
Globals model, site, culture, request (path, query, url, host), user (id, name, email), body
Node members properties by name; id, type, url, created, changed
Files url, name, size, content_type, extension, width, height, title, description
Functions content.get id_or_url, content.children, content.parent, content.ancestors, content.list type { take, skip, order, descending }, content.url, image.url file { width, height, mode, format } (a file no picture can be made of, such as an SVG drawing, gives its own URL), asset.url path (the address of a file of the template's library: a text file such as a stylesheet or script by the hash of its text, another file at its own address: <link rel="stylesheet" href="{{ asset.url "css/site.css" }}">; it changes when the file does), include path, raw, preview.on, preview.field node property, preview.page node, design.profile [key] (a design profile: the site's own, the only one when the site names none, or the one of a key; its fields by name: {{ (design.profile).Logo | image.url { height: 48 } }}, Css, Files)

Scriban's string, array, date, math, html, object, regex and timespan are there too.

Editing from the CMS preview

On the pages the CMS interface's preview loads, a value written straight from the data marks the element it lands in with data-relatude-field (<h1>{{ model.Headline }}</h1>, <img src="{{ model.Picture.url }}">), so a click on it opens the field, inner nodes too. A value a function changed, and a list, is marked by hand; outside the preview these write nothing:

<strong{{ preview.field model "TonnesPerYear" }}>{{ model.TonnesPerYear | math.format "N0" }}</strong>
<div class="cards"{{ preview.field model "Children" }}>…</div>
{{ if preview.on && !model.Picture }}<div class="empty"{{ preview.field model "Picture" }}>Add a picture</div>{{ end }}

ScribanOptions.MarkFields = false turns the automatic marks off.

Emails, feeds, any text

var body = await templates.RenderAsync(db, "emails/order-confirmation.sbn", order);          // ITemplateRenderer, a path in the design library
var html = await templates.RenderTextAsync(db, mail.Body, "sbn-html", order);               // a template kept in a property
var result = await templates.RenderToAsync(output, db, "feeds/news.sbn-html", news, new TemplateRenderOptions { Http = http });
// result.ContentType: the front matter's content_type, such as application/rss+xml

Functions of your own

public sealed class ShopFunctions : IScribanExtension {
    public void Register(ScribanApi api) => api.Object("shop", "The shop's helpers")
        .Function("price", Price, "The product's price for the visitor.", "shop.price product");
    static string Price(TemplateContext context, object product) =>
        ScribanContext.Of(context).NodeOf(product)?.Get("Price") is decimal p ? p.ToString("N2") : "";
}
builder.Services.AddScribanExtension<ShopFunctions>();

Limits

Every render has a context of its own (never reset and reused) and stops past ScribanOptions: Timeout (2 s), LoopLimit (10,000), RecursiveLimit (100), OutputLimit (10,000,000 characters), MaxIncludeDepth (16), MaxLayoutDepth (8). A failing page answers 500, with the file, line and column in the log, and on the page in the CMS preview and in Development. Scriban is pinned at 7.6.1 or later.

In the CMS interface a template opened in the file library opens in a code editor that colours and checks the language, with a preview with a node of the template's model type and the reference; the Templates blade (from Settings) lists the page templates. Its commands are templates.* (see the Relatude.CMS package).

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.1.11.42-alpha 0 11/24/2026
1.1.11.35-alpha 42 11/22/2026
1.1.10.34-alpha 45 11/22/2026
1.1.10.32-alpha 43 11/22/2026
1.1.9.30-alpha 46 11/20/2026