What is a Template?
, so I am going to attempt to collect some here based on examples I find and uses I develop that are reusable. If you come across this and know of a more complete or authoritative source of information please add in the comments.
The Kendo template is not a single implementation or technique to be defined. So I will attempt to arrange a series of template implementations along a range of complexity.
- The simplest might be an inline declaration that is part of a dataSource definition for a grid.
Kendo Template Definition Methods
<script id="template" type="text/x-kendo-template">
var template = kendo.template($("#template").html());
Template Inclusion Syntax
Kendo lists the very limited template syntax in their documentation:
- Render literal values: #= #
- Render HTML-encoded values: #: #
escaped vs. unescaped example:
Kendo does not employ any other syntax inside templates. The design decisions around using the # delimiter for templates is refreshingly public. Kendo’s Template overview is buried here.
Simplest Template Applications
In the context of a Kendo object definition, such as kendoGrid columns:
Template: '#= kendo.toString(BirthDate,"dd MMMM yyyy") #'
Populating a list view so that data elements returned by the dataSource are displayed within the list. For example:
A template can be applied to a div tag, replacing it’s contents with a mix of static template contents and variable data.
Intermediate Template Applications