How to use the Latte function

Verze:

17. 02. 2022

Zodpovědná osoba:

Dominik Šlechta

HTML/Latte style notation

we use latte functions - foreach, include, if, etc. for simplicity and reusability of elements.
Basic latte functions can be found on this page.

Example of using foreach

                        {foreach $nav as $item}
                            <li class="menu__item">
                                <a href="{$item|link|noescape}" class="menu__link --link-rev">
                                    {$item|name|striptags}
                                </a>
                            </li>
                        {/foreach}

Example of using the n:if function

n:foreach, n:if, n:ifcontent, n:class functions are used directly in the tag

                <div class="rubrics" n:if="isset($rubrics) && count($rubrics) > 0">
                    <h3 class="rubrics__title">
                        {$web['BLOG_RUBRICS']}
                    </h3>
                    {foreach $rubrics as $item}
                        {var $childrenCount = count($item['chilldren'])}
                        <a class="rubrics__item" href="{$item|link|noescape}">
                            {$item|name|noescape} ({$childrenCount})
                        </a>
                    {/foreach}
                </div>