Templates
Templates
5h3ll-ui-cli is deprecated
Template files now ship with 5h3ll-ui. If you previously copied templates with 5h3ll-ui-cli, install 5h3ll-ui instead and copy the files from node_modules/5h3ll-ui/templates.
5h3ll-ui ships optional Nunjucks and Jinja macros for components with larger HTML structures. They generate the same semantic 5h3ll-ui markup shown in the component docs, while keeping repeated server-rendered markup easier to maintain.
The templates are versioned with 5h3ll-ui, so the generated markup matches the CSS and JavaScript files you installed.
Macros
Some macro files include internal recursive helpers such as render_select_items(). Those helpers are implementation details and are not part of the public API.
Usage
Install Templates
Copy the template folder for your template engine from 5h3ll-ui. Templates are meant to be app-owned, so you can edit them after copying.
cp -R node_modules/5h3ll-ui/templates/nunjucks ./templates/5h3ll-uicp -R node_modules/5h3ll-ui/templates/jinja ./templates/5h3ll-uiCopy only the files you use if you do not want the full template folder.
You can also copy the Nunjucks templates or Jinja templates from GitHub.
Use a Macro
Import a macro from the copied template file, then call it with the props for that component.
{% from "5h3ll-ui/select.njk" import select %}
{{ select(
name="fruit",
items=[
{ value: "apple", label: "Apple" },
{ value: "banana", label: "Banana" },
{ value: "blueberry", label: "Blueberry" }
]
) }}{% from "5h3ll-ui/select.html.jinja" import select %}
{{ select(
name="fruit",
items=[
{ "value": "apple", "label": "Apple" },
{ "value": "banana", "label": "Banana" },
{ "value": "blueberry", "label": "Blueberry" }
]
) }}