Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic generation of stream block factories #87

Open
8 tasks
jams2 opened this issue Feb 19, 2024 · 0 comments
Open
8 tasks

Add automatic generation of stream block factories #87

jams2 opened this issue Feb 19, 2024 · 0 comments

Comments

@jams2
Copy link
Contributor

jams2 commented Feb 19, 2024

Currently, to use stream field factories for non-trivial stream fields, a user needs to:

  • define each block as a class, avoiding the inline declaration syntax; and
  • create a block factory class for each distinct block class.

This means a typical Wagtail codebase may have tens of block factory classes that provide little other than boilerplate, and maybe some default values.

We should provide functionality for automatically generating the block factories, so that users of the library can avoid writing boilerplate for boilerplate's sake.

An ideal implementation would:

  • allow users to use stream field factories without declaring any block factory classes;
  • allow users to explicitly declare and use block factory classes, including them at the root of the tree (i.e. as the stream field factory entrypoint - matching current behaviour);
  • allow users to explicitly declare and use block factory classes, including them at arbitrary points in an otherwise automatically generated tree of block factories;
  • declare default values for block factories or their fields, at arbitrary points in the tree;
  • generate block factories lazily - only when they're required;
  • cache any generated block factories, so that effort isn't repeated;
  • continue to work with the existing syntax for specifying block values; and
  • include proper documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant