Token Templates
Token Templates will generate HTML - often based on the data a editor entered, and/or which was provided from the App.
Note
The View determines which template file is being loaded.
Tip
Token templates are by far not as powerful as Razor Templates. We always recommend Razor.
Example Template
<h1>[Header:Title]</h1>
<ul>
<repeat>
<li><a href="[Content:Link]">[Content:Title]</a> [Content:Toolbar]</li>
</repeat>
</ul>
How it Works
Token templates use a Token Engine to generate Html. The convention uses placeholders like [Scope:Property]
to put data into the Html.
The template files usually reside inside app root folder or sub folder. These end with .html
.
Placeholders and code usually is marked with [...]
like [Content:Name]
.
Internally the Token-Engine uses LookUps to find what can be shown.
Tip
Tokens are very limited, we strongly recommend to use Razor Templates templates instead.
Read more about it in the Token Basics
Content, Presentation and Toolbar Tokens
[Content:PropertyName]
like[Content:FirstName]
[Content:Presentation:PropertyName]
like[Content:Presentation:UseLightbox]
[Content:Toolbar]
to get a Toolbar for the Content-object with it's Presentation
Token Toolbars only support the basic toolbar, not the newer TagToolbar. Read more about Toolbars.
Header Tokens
Note that in Token-templates the Header
is called the ListContent
for historical reasons, not Header
like in Razor.
[ListContent:PropertyName]
like[ListContent:Title]
[ListContent:Toolbar]
for the toolbar[ListContent:Presentation:PropertyName]
like[ListContent:Presentation:UseLightbox]
Common LookUp Sources
- App Sources
- App - the current App, which can give you folders (to link JS files) ☢️🩸
- App:Settings - app settings ☢️🩸
- App:Resources - app resources, translated labels etc. ☢️🩸
- Web Server and System Sources Hybrid
These work both on Dnn and Oqtane (2sxc 12+)[Query]
☢️🩸
- Web Server and System Sources
- QueryString - url parameters ☢️
- Form - form post parameters ☢️
- DateTime - current date/time information ☢️🩸
- CMS / Dnn Sources
- User Information Sources
- User
- Membership
- User Profile
Read more about LookUp Sources
Repeaters / Lists
Token templates have a trivial mechanism to loop through lists. Note that we strongly recommend you use Razor Templates instead. Here's how it works:
<ol>
<repeat repeat="Item in Data:Default">
<li>
[Item:Title] [Item:Toolbar] <br>
<a href="?details=[Item:UrlKey]">Details...</a>
</li>
</repeat>
</ol>
In a repeater the Toolbar can be added using [repeater-name:Toolbar]
.
Read also
History
- Introduced in 2sxc 1.0