Template

<script type="edgeside/template" ...>

The template element is used to render a fragment of the page a site visitor sees in the browser, which may contain dynamic data. It can consume data from the 'context' when it is processed on the edge (which might come from a call to some external service, for example), and use this data as input to be rendered using its template.

Attributes

Name Description Required?
data-edgeside-input specifies a key under which the template processor can expect to find the data it needs to populate the template. yes

Element content

A template written in the Mustache templating language.


Examples

example1 - Render Some Data

We'll need some data for our template, in this case we'll use the REST element to fetch some time data and make it available under the key 'time'. Then we can use the Template element to render it with a template that uses Mustache syntax. Note that we need to use the same value for the key ('time').

<script type="edgeside/rest"
data-edgeside-output="time"
data-edgeside-endpoint="http://worldtimeapi.org/api/timezone/Europe/London"
>
</script>

<script type="edgeside/template"
data-edgeside-input="time">

<h2> In London it is {{datetime}}</h2>
</script>

Live Results:

Live Results (Source):