Code Islands

As a template language, Jtwig allows one to have formatting logic around content. In order to do so, Jtwig uses the so called Code Islands. This is similar to many template languages and identical to Twig’s syntax.

{% ... Jtwig code here ... %}

Jtwig code islands begin with {% and ends with %}, just as simple as that.

White space control

Tied up with the code island syntax is another syntactical enabled feature, 100% compatible with Twig, 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 Jtwig code island. Let's take for example:

{% ... jtwig code ... -%} text {%- ... jtwig code ... %}

Such code will produce text without white spaces.

Comments

In Jtwig there are only multiline comments.

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

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

{#- Comment... -#}

Output

In Jtwig there is only one way to write the value of an expression (the definition of expression will be detailed afterwards) to the output. That is accomplished with the print operation as shown below.

{{ expression... }}

Output constructs also support white space control feature in the same way as code islands.

{{- expression... -}}