ebsco / edsapi-drupal-plugin

A Drupal modules for the EBSCO Discovery Services API
Apache License 2.0
1 stars 3 forks source link

Drupal 8 Theming best practices #16

Closed jameswilson closed 3 years ago

jameswilson commented 6 years ago

Drupal 8 has overhauled various aspects of the theming layer. They introduced Twig with the aim of preventing business logic from display template files. There are other benefits to using Twig such as increased security for printed strings via the built in auto-escaping. Along with the move to Twig came a number of general best practices about how to structure the code that the Ebsco module doesn't follow, which makes it very complicated to override.

For example, it appears that all of the display logic basically lives in template_preprocess_ebsco_result file, instead of separating business logic (like preparing variables for display) into preprocess and the actual display logic (like rendering the data in a table layout) in the twig file.

The basic strategy for preprocess functions can be summarized with these two methods:

The module needs a fairly extensive overhaul to do the following tasks