Load templates from server-side data using Razor code to build the JSON. Templates can be pulled from a database or configuration.
@{
var templates = new List<object>();
var templateNames = new[] { "Invoice", "Receipt", "Shipping Label" };
foreach (var name in templateNames)
{
templates.Add(new
{
name = name,
html = $"<h2>{name}</h2><p>Dynamic content...</p>"
});
}
var htmlTemplatesJson = JsonSerializer.Serialize(templates);
}
<richtextbox
name="dynamicTemplatesEditor"
toolbar="full"
height="400px"
html-templates-json="@htmlTemplatesJson" />