RFC: Collections
giuseppeg opened this issue · comments
Giuseppe commented
xm should be able to render collections of data. For this I imagined we could use a <fill>
tag with a new attribute called from
(name can be changed).
from
takes an array of flat objects (a string of JSON), iterates over them and repeats its content while filling the slots:
For advanced use cases from
accepts:
- glob patterns (grab fills from other HTML files)
- JSON file paths
- path to a JS module that exports an array or a function
- path to a JS module that exports an async function
The async function version is super powerful 💣
async functions can be used to fetch data from an API, database and perform any other asynchronous operation!