--- title: "Template Coding" slug: "template-coding" updated: 2024-10-25T11:15:16Z published: 2024-10-25T11:15:16Z canonical: "learn.servitly.com/template-coding" --- > ## Documentation Index > Fetch the complete documentation index at: https://learn.servitly.com/llms.txt > Use this file to discover all available pages before exploring further. # Template Coding Servitly uses a template-based model to render widgets and display information, including metric data, statistics, and properties values. A template is a piece of HTML5 that includes: - Structure elements used for content positioning in a responsive way - UI Components compatible with the context of the template (e.g. customer details, thing details). - Custom HTML which used CSS and Angular components. ## Layout You can use the [*Boothstrap 4.6*](https://getbootstrap.com/docs/4.6) CSS classes to arrange UI Components within the page, for instance, it is possible to use the *Flex* layout or the *Grid System*. Note that, only the Flex layout is recognized by the Design View in the Template Visual Editor. ### Flex The following example generates one row, with two cells that fit the entire space of the row. ```xml
``` Depending on the available space or screen size, the cells will be automatically resized and wrapped into new rows. See the [Bootstrap Flex](https://getbootstrap.com/docs/4.6/utilities/flex/) page for more details. ### Grid System The following example generates a row, with two cells. ```xml
``` Each cell will fit the space differently according to the screen size: - **CELL 1** will fit 6 columns (half space) on medium and small screens, and the whole row in case of extra-small screens. - **CELL 2** will fit 2 columns on medium and small screens, and the whole row in case of extra-small screens. This approach allows driving the way how the components will respond depending on the available screen size. See the [Bootstrap Grid](https://getbootstrap.com/docs/4.6/examples/grid/) page for more details. ## Attributes Encoding In addition to the standard HTML attributes, widgets allow defining more specific attributes that are used to configure the widget itself, for instance, considering the following sample, the attributes *iconName*, *name,* and *filters* are widget specific attributes. ```plaintext ``` Depending on the type of the attribute value, a different syntax must be used: ### STRINGS ```xml ="" ``` In some cases, you can also find and use the oldest syntax based on squared brackets. ```xml []="''" ``` ### BOOLEAN ```xml []="true" []="false" ``` Due to a Javascript limitation in recognizing types, booleans always require the squared brackets' syntax, for instance, if you write ="false", this is always intended as true. ### NUMBERS ```xml []="123" ``` You need to use the squared brackets' syntax to pass the attribute value as a number object instead of a simple STRING. ### JSON OBJECTS ```xml []="{'foo': 'xyz', 'bar': 123, 'baz': true}" ``` You need to use the squared brackets' syntax to pass the attribute value as a JSON object instead of a simple STRING. ## Include templates Templates can include other templates by using the *include-template* element. ```xml
``` The *include-template* element searches for the template by name, if not present, nothing is printed. In this way, in the case of a thing-definition hierarchy, it is possible to create a dashboard whose fragments are redefined within the sub-thing-definitions, allowing common parts reuse. ## Link Element Link-element components can be used to place a navigation link as a button within pages or widgets. Refer to the [Link Element](/docs/link-element-widget) article for more details.