giuseppeg / xm

₪ extensible HTML
https://giuseppeg.github.io/xm
326 stars 9 forks source link

RFC: Support slot attributes and data cascade #16

Open giuseppeg opened 3 years ago

giuseppeg commented 3 years ago

⚠️ this feature is related to the Collections proposal and probably should be implemented before #17.

slot attributes

Currently xm support only element slots:

<slot name="title"></slot>

We should add support for slot attributes:

<a slot:href="https://{domain}/contact">contact me</a>

These will be filled with fill elements eg:

<fill name="domain">acme.com</fill>

spec

Any attribute can be slotted if prefixed with slot:. Within the value for the attribute there can be multiple expressions delimited with { and }. The expression name matches a fill name, and xm replaces the expression with the fill value.

Data Cascade

xm should allow to define multiple sources for data, including a global data object that is provided via config file.

We need to rework the main plugin to merge the data correctly using a Data Cascade mechanism similar to the 11ty's one. Check out https://www.11ty.dev/docs/data-cascade/

Additionally we need to provide a global xm:permalink fill value that contains the absolute path for the file so that people can use it to reference to the current page (eg. when creating sharing links). The xm: namespace will be reserved for xm fill values.