giuseppeg / giuseppeg/xm

RFC: Collections

Open
#17 0 comments 0 reactions 0 assignees View on GitHub
help wanted RFC
Dominant language
JavaScript
Stars
323
Forks
9
PR merge metrics
No merged PRs in 30d

Description

⚠️ **this feature is strictly related to the data cascade proposal from #16 and probably should be implemented either together or after the data cascade is implemented**.

xm should be able to render collections of data. For this I imagined we could use a `` 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:

![EniH6fWW4AAgNU1](https://user-images.githubusercontent.com/711311/108487868-01796980-72a0-11eb-95fa-702e9c70a33b.jpeg)

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

![EniI0OWXcAITSQ0](https://user-images.githubusercontent.com/711311/108487940-16ee9380-72a0-11eb-98b0-266448ea8d8c.jpeg)

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!

![EniJ0LmXYAAMQXk](https://user-images.githubusercontent.com/711311/108488067-3eddf700-72a0-11eb-8540-65a7f448fafb.jpeg)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.