Engine syntax
for Liquid.json only
Interpolation
Interpolation is a way to print out the dynamic data inside the HTML structure.
Syntax | Description |
@print(variable) | Print out the variable |
@lang(variable) | Print out the variable or string which will be supported multiple |
@attr() | Print out the escaped of variable into attribute of HTML element |
Evaluate
The engine is built in Javascript, In some situations, it's useful to embed logic code into your views. You can use the blade @js directive to execute your logic code. It works similarly to <?php
and ?>
in PHP programming language.
Name | Syntax |
Start | @js |
End | @endjs |
Conditionals
You may construct if statements using the @if
, @elseif
, @else
, and @endif
directives. These directives function identically to their Javascript counterparts:
Name | Syntax |
if | @if (conditions) |
else if | @elseif (conditions) |
else | @else |
endif | @endif |
unless | @unless(!conditions) |
For convenience, Blade also provides an @unless
directive:
Switch case
Switch statements can be constructed using the @switch
, @case
, @break
, @default
and @endswitch
directives:
Name | Syntax |
switch | @switch (variable) |
case | @case (value) |
break | @break or @endcase |
default | @default |
endswitch | @endswitch |
For Loop
In addition to conditional statements, Engine provides simple directives for working with Javascript's loop structures. Again, each of these directives functions identically to their Javascript counterparts:
Name | Syntax |
for | @for (contitional statements) |
endfor | @endfor |
elsefor | @elsefor // incase array has no items |
endelse | @endelse |
While loop
Name | Syntax |
while | @while (conditions) |
endwhile | @endwhile |
If you love LayoutHub, could you consider posting an review? That would be awesome and really help us to grow our business, here is the link.
Last updated