kingsdigitallab / django-kdl-wagtail

A collection of Wagtail components used across several KDL projects
MIT License
4 stars 0 forks source link

Framework-dependent sets of templates #4

Open geoffroy-noel-ddh opened 5 years ago

geoffroy-noel-ddh commented 5 years ago

Another topic that came up during conversations between GF, BM and GN.

There seem to be 3 possible choices for front-end framework on our research project site:

  1. Foundation:
  2. Bulma: useful for developers to work more independently on prototypes; Weill probably never be used on high-traffic pubic site.
  3. No-framework: preferred by Tiffany

One idea suggested by BM would be to have three templates folders under each app (e.g. core, people and also bare-bones):

One constant in settings/local.py would determine which framework is used and kdl-wagtail would draw the templates from the relevant folder automatically.

Despite being separate folders, care should be taken to keep the template names and internal structure (e.g. includes, template blocks) compatible between frameworks.

There are risks however of divergence and code duplication. One way would be to have abstract templates above all that, with only the template blocks and context specification. templates-X would inherit from those. But this would create yet another level of abstraction and would probably be too complicated: framework-independent > framework-specific > project-specific .

jmiguelv commented 5 years ago

Instead of 3 different folders, could we do it with subfolders instead? Something like https://github.com/rkhleics/wagtailmenus/tree/2fee81fd587055de26eab9240f174f344d129b68/wagtailmenus/templates/menus. That way we wouldn't need to repeat all the templates in the 3 different folders.

geoffroy-noel-ddh commented 5 years ago

That's another option, but then the framework selection can't be done with a single constant in local.py, you'd have to explicitly include the templates for your particular framework.

A third options would be to let kdl-wagtail always look into /templates then /template-X (where local.py KDL_WAGTAIL_UI_FRAMEWORK = 'X'). So we don't need to copy templates if they don't need modifications.