HTML
Last updated
Last updated
Our HTML component was designed so you have the maximum flexibility to build your own components on the exact way you want. To have a better view on the code editor and the component itself, you can double click on the preview canvas.
To enhance your productivity, we have native integration with .
You can differentiate between dynamic variables and static text in your templates. Here’s how it works:
• Simple Variable: Enclose your text in double curly brackets: {{ }}
.
• HTML Variable: Enclose your text in triple curly brackets: {{{ }}}
to include HTML tags.
On handlebars, you can use if
, else
, unless
syntax to conditionally render a block of code.
If you want to only render a block when a variable is sent:
If you want to conditionally render with a fallback:
You can also use the alternative to NOT render a block when a variable is sent:
On handlebars, you can either loop through arrays or objects.
Heres how to loop through an array of strings:
Heres how to loop through an array of objects:
Hint: When you loop through an array, you have access to this variable {{@index}}
, which returns the index of the array item.
Heres how to loop through an object:
Hint: When you loop through an object, you have access to this variable {{@key}}
, which returns the key of the looped object.
Heres how to loop through an a nested array of objects:
Array of Objects Example:
The syntax would be:
You can use them on your HTML component with the following syntax:
You won't be able to see the Icon on the preview canvas yet, but if you click on "Generate sample", you'll be able to see the icon.
Hint: You can set your icon to data-lucice="{{icon}}"
to pass the icon as a variable from the payload.
We use as our templating engine, so you also have all the flexibility that handlebars delivers inside your html components.Here's some examples:
To see more handlebars functions, you can check out their .
We also have a native integation with .