Template

Introduction

Exception provides Twig template engine native implementation.
View resources are stored into apps/APP-NAME/views folder with .html or .twig extentions.
By default, Exception cache all Twig views into apps/APP-NAME/cache and you can set or unset cache into envs/ENV-FILE.php configuration file.

You can recall a view into a controller or a route using getview() function.
Remember to specify the echo getview() to "print" the view in the page.

Getview function lets you specify path of the html twig template file and an variables array to use into template (optional):

echo getview("pages/about", $vars);

Rememeber that HTML-PATH is the path of twig html template into apps/APP-NAME/views without ".html" or ".twig" extention and VARS are optional.

A full documentation of Twig is here: https://twig.symfony.com/doc/2.x/

Since 1.3.2 version or higher you can exlude Twig engine and use PHP file as view (in some case can be useful). You have to recall a PHP view with

getview(PHP-PATH, VARIABLES, 0)

Rememeber that PHP-PATH is the path of php template into apps/APP-NAME/views without ".php" extention and VARS are optional.

Examples

Print variable

{{ varname }}

Print array variable

{{ arrayname.varname.subvaname }}

Loop an array

{% for item in items %}

{% endfor %}


Conditions

{% if conditionvar == TRUE %}

{% else %}

{% endif %}


Inclusions

{{ include('common/sidebar.html', ignore_missing=true) }}

Print RAW variable (with HTML tags)

{{ varname|raw }}

Do you need help?

Write me an e-mail: [email protected]