Table of Contents

Interface ITemplateEngine

Namespace
ToSic.Sxc.Services.Template
Assembly
ToSic.Sxc.Services.dll

Engine which parses a template containing placeholders and replaces them with values from sources.

[WorkInProgressApi("namespace not final")]
public interface ITemplateEngine

Remarks

Released in 18.03

Methods

GetSources(NoParamOrder, int)

Get a list of underlying sources, mainly for debugging.

IEnumerable<ILookUp> GetSources(NoParamOrder npo = default, int depth = 0)

Parameters

npo NoParamOrder
depth int

Returns

IEnumerable<ILookUp>

Parse(string)

Basic Parse functionality. This is the variant without parameters, which should be used in basic cases and also for passing into function calls, like into CMS HTML Tweaks.

string Parse(string template)

Parameters

template string

The string containing the token placeholders like Hello [User:FirstName]

Returns

string

Parse(string, NoParamOrder, bool, IEnumerable<ILookUp>?, int)

Basic Parse functionality with more options.

string Parse(string template, NoParamOrder npo = default, bool allowHtml = false, IEnumerable<ILookUp>? sources = null, int recursions = 0)

Parameters

template string

The string containing the token placeholders like Hello [User:FirstName]

npo NoParamOrder

see Convention: Named Parameters

allowHtml bool

allow adding html to the string - if false (default) will html encode anything found for safety before replacing something

sources IEnumerable<ILookUp>

A list of sources to use for this parse - otherwise use the sources provided on creation of the template engine

recursions int

Recursion depth for tokens-in-tokens. Could leak unexpected information, if a token contains user provided data or url-parameters so use with caution. Defaults to 0 for safety, added v20.09

Returns

string