giuseppeg / xm

₪ extensible HTML

Home Page:https://giuseppeg.github.io/xm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RFC: Collections

giuseppeg opened this issue · comments

⚠️ 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 <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:

EniH6fWW4AAgNU1

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

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