You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
parser uses HTM to parse JSX-like input into a workable element tree. However, since HTM operates on template strings and we need parse to work on plain strings, we also dangerously use eval to "hydrate" these templates.
generator operates on parser'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 on eval. It assumes that the only environmental requirements to evaluate generated block code are Preact and WP primitives, so it requires those modules before calling eval.
Caveats
eval is recklessly used. Consider switching to a sandboxed alternative (e.g. safeEval).
Poorly tested, naively approached.
feel free to expand
About
A quick exploration in generating Gutenberg blocks from string templates