rmorse / babel-plugin-jsx-template-vars

A Babel transform for rendering a template version of your React / Preact app. Useful for generating a pre-render for SSR.
MIT License
10 stars 0 forks source link

Automatically detect list start / end #1

Closed rmorse closed 2 years ago

rmorse commented 2 years ago

At the moment, we're using comments to manually tag where a list (repeatable item) starts and ends - directly in the return of a component.

Eg:

{ /* Template Props: list-start: options */ }
{ options }
{ /* Template Props: list-end: options */ }

We should be able to to detect lists automatically (and insert the start/end tags) by following the variable from the components props, down into the return.

To achieve this, we just need to declare some setup information about this prop in our templateProps definition and then start tracking it.

I think this would be a good start and allow autodetection for a good number of user cases:

There must be some other cases I'm not thinking of?

If this is implemented, I think we should still allow for comments to manually tag lists (as a fall back) - but then we might get an issue of double tagged lists... I think this might be ok though.

rmorse commented 2 years ago

Resolved in the latest update