npm i
npm test
-
parser
uses HTM to parse JSX-like input into a workable element tree. However, since HTM operates on template strings and we needparse
to work on plain strings, we also dangerously useeval
to "hydrate" these templates. -
generator
operates onparser
's element tree to generate Gutenberg code as a plain string. -
evaluator
turns string-based generated code into a usable Preact component. This isn't strictly needed for a simple JSON-to-JS code generator, but is useful for testing the generator. This piece also relies oneval
. It assumes that the only environmental requirements to evaluate generated block code are Preact and WP primitives, so it requires those modules before callingeval
.
eval
is recklessly used. Consider switching to a sandboxed alternative (e.g. safeEval).- Poorly tested, naively approached.
- feel free to expand