Quantcast
Viewing all articles
Browse latest Browse all 295165

Supply front matter metadata to preprocess functions

Problem/Motivation

#3064854: Allow Twig templates to use front matter for metadata support introduces the ability for Twig templates to contain front matter metadata.

It would be very helpful to themes to also supply this information to preprocess functions.

One strong use-case being to preprocess the same type of theme hook/template, but for different supported versions where the markup or render structure may have changed between versions.

For example, in Drupal Bootstrap, there could be two templates that are for the same theme hook, but one specifies:

---
bootstrap:
  version: >=3.0.0 <4.0.0
---

While the other template specifies:

---
bootstrap:
  version: >=4.0.0 <5.0.0
---

Being able to access this data in a preprocess function is vital to determine which version of the theme hook/template should be rendered.

Proposed resolution

TBD

Possible solutions:

  1. During the theme registry phase, load the template and add the front matter metadata to the theme hook info array.
  2. Create a hook for theme engines to supply additional metadata for the template in question prior to invoking preprocess functions.
  3. A more permanent and likely performant solution would be to use #3075427: Create TemplateDiscovery for plugin managers to use along with #2869859: [PP-1] Refactor theme hooks/registry into plugin managers so it's just part of the template definition upon discovery.

Remaining tasks

  • Create tests
  • Create patch

User interface changes

None

API changes

TBD

Data model changes

None

Release notes snippet

TBD


Viewing all articles
Browse latest Browse all 295165

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>