Template engine for logic
The system uses the templating language RainTPL.
It allows to do conditions (if / else / elseif) and allows your to add flexibility.
<div class="hero">
{if=" '#$variable|subtitle$#' != '' "}
<h1 class="hero__title h1">#$variable|title$#</h1>
<p class="hero__subtitle h2">#$variable|subtitle$#</p>
{else}
<p class="hero__breadcrumb">#$function|breadcrumb$#</p>
<h1 class="hero__title h1">#$variable|title$#</h1>
{/if}
</div>
Example in a hero block: if the variable “subtitle” is not empty in the backoffice, we display the subtitle, else we show the breadcrumb.
Rendering (advanced)
The rendering of the page will first
replace CMS variables
replace unit content
then at the very end, RainTPL applies the conditions (
if / else if/ else
)
Because of this, on a block that loads conditionally unit loops, it can cause performance issue on the platform.
Example of syntax that can cause performances issues:
{if=" '#$variable|module-type$#' == 'room' "}
#$loop|{room}|{a}| $#
<div>{a.name}</div>
#$/loop|{room}|{a}| $#
{elseif=" '#$variable|module-type$#' == 'offer' "}
#$loop|{offer}|{a}| $#
<div>{a.name}</div>
#$/loop|{offer}|{a}| $#
{elseif=" '#$variable|module-type$#' == 'hotel' "}
#$loop|{hotel}|{a}| $#
<div>{a.name}</div>
#$/loop|{hotel}|{a}| $#
{else}
<p>Wrong module</p>
{/if}
Here, Galaxy will get unit data for rooms, offers, hotels. Then RainTPL will compile the template with the conditions.
If the website has a lot of rooms, offer, hotel, etc.. it will be slow for 2 different reasons:
long time to get the unit data
then, very large template for RainTPL to compile
#$start-if|#$variable|module-type$#|==|room$#
#$loop|{room}|{a}| $#
<div>{a.name}</div>
#$/loop|{room}|{a}| $#
#$else-if|#$variable|module-type$#|==|offer$#
#$loop|{offer}|{a}| $#
<div>{a.name}</div>
#$/loop|{offer}|{a}| $#
#$else-if|#$variable|module-type$#|==|hotel$#
#$loop|{hotel}|{a}| $#
<div>{a.name}</div>
#$/loop|{hotel}|{a}| $#
#$else$#
<p>Wrong module</p>
#$/end-if|#$variable|module-type$#|==|room$#
Syntax details: it checks that #$variable|module-type$#
== room
#$start-if|#$variable|module-type$#|==|room$#
#$/end-if|#$variable|module-type$#|==|room$#
Last updated