---
url: https://docs.juniper.bot/en/message-templates/advanced/code-islands.md
description: Code Islands syntax of the JuniperBot template engine.
---

# Code Islands { #code-islands }

In its simplest form, a template is a text that will be sent as message as is.

However, the whole point of the template engine is the ability to format this text in a given way, use control
structures (conditions or loops) inside it, and even perform some actions. The "code islands" are used to do that.

## Code { #code }

Code islands begin with `{%` and ends with `%}`, just as simple as that. [Tags](tags) are used inside code constructs
to implement a control structures (conditions or loops), declare variables and much more.

```template
{% tag %}
```

Each code construct can perform only single operation or declare part of a control structure.

The logical sequence is formed by using many separate islands of code for each individual operation or part of the control structure.

## Whitespace Control { #whitespace }

Tied up with the code island syntax is another syntactically enabled feature, the white space control functionality.
This allows one to remove white spaces before or after a code island. In order to accomplish that, append/prepend the
symbol `-` to the beginning/ending of the code island. Let's take for example:

```template
{% if (1 == 1) -%}     text     {%- endif %}
```

Such code will produce `text` without white spaces.

## Output { #output }

In JuniperBot Template Engine there is only one way to write the value of variable or an expression to the output.
That is accomplished with the print operation as shown below:

```template
{{ expression }}
```

Note that output also support the white space control feature, using the same approach as per code islands:

```template
{{- expression -}}
```

## Comments { #comments }

In template engine you can add comments that will not be printed anywhere:

```template
{# This is the content of the comment.
And it can be a multi-line content. #}
```

Again, comment constructs also support white space control feature in the same way as code islands:

```template
{#- Your awesome comment -#}
```
