askonomm / htmt

A templating library with native AOT support for .NET projects.
9 stars 0 forks source link

Implement `foreach` attribute parser #32

Open askonomm opened 6 hours ago

askonomm commented 6 hours ago

It would be what the ForAttributeParser already is, except it would allow expression modifiers and keys/indexes. Ultimately this would replace the for attribute in some future release where I feel like breaking backwards compatibility.

A simple example:

<div data-htmt-foreach="posts as post">
    ...
</div>

With key/index:

<div data-htmt-foreach="posts as key, post">
    ...
</div>

And with modifiers:

<div data-htmt-foreach="posts | reversed as key, post">
    ...
</div>
askonomm commented 5 hours ago

Also would be nice to add more expression modifiers that are specifically meant for IEnumerable types such as offset, limit, filter, etc.