figma / code-snippet-editor-plugin

Translate component variants, properties, and more into dynamic code snippets for your design system.
https://www.figma.com/community/plugin/1311777988952403297/code-snippet-editor
MIT License
126 stars 11 forks source link

Recursive Params #49

Closed jake-figma closed 4 months ago

jake-figma commented 4 months ago

Working to improve params generation per #48

Essentially, we are generating all the params (including recursive children) upfront before compiling templates.

Until now, params generation and children traversal has been coupled to compilation making it hard to test and certain statements impossible. "will any of this node's children render in this template?" is a better and different question than, "does this node have children with a snippet template?" which is different than the more primitive and currently supported, "does this node have children?"

This is no longer a limitation, allowing statements like {{?figma.children}} (if any children will render for this template) and {{!figma.children}} (if no children render for this template).

See test.ts for a sense of what's possible. Params objects can contain children and child templates. They hydrate templates and can be compared to expected strings. This means we can test and preview full recursive template compilation outside the Figma environment.

Still have some cleanup to do, but this is a big first step towards optimal params generation.