patbenatar / rbexy

A Ruby template language and component framework inspired by JSX and React
MIT License
35 stars 5 forks source link

Expose an API for AST transforms #53

Closed patbenatar closed 3 years ago

patbenatar commented 3 years ago

Not sure if it's necessary to allow for any type of node to be transformed, but we could provide an API that allows devs to register transforms for certain types of nodes, e.g.:

Rbexy.config.transforms.register(HTMLAttr, ComponentProp) do |node, context|
  # mutate node to your pleasing
end

Example use case: intercept class="..." class names and apply CSS Modules scoping to them.