Skip to content
This repository has been archived by the owner on Jun 10, 2019. It is now read-only.

Latest commit

 

History

History
30 lines (13 loc) · 2.19 KB

README.md

File metadata and controls

30 lines (13 loc) · 2.19 KB

Multiple Definition Files

This Drupal 8 module enables multiple definition files for theme asset libraries and layouts.

Installing

Install and enable just like any other Drupal module. No configuration required.

Motivation

One of the principles in Twig component based theme development is that all files related to a particular component should be located in a component specific folder. However, currently Drupal core only supports extension (theme) specific definition files for asset libraries and templates. This module enables component specific definition files to be located in component folders.

How it works

The theme folder of the default theme is recursively scanned for definition files. All found definitions are then merged into the existing/a new main theme definition file using hook_library_info_alter() and hook_layout_alter(). From the perspective of Drupal core, everything should work just the same as if all definitions were in the main theme specific file.

Notes on layout templates

Please note that the templates defined in .layout.yml files should use the .html.twig suffix.

The contents of regions defined in .layout.yml files are by default accessible in Twig templates under the content variable. So the contents of a main region would be displayed with {{ content.main }}. To aid in creating less Drupal specific component templates, this module also makes layout region variables available in the Twig context root. This makes it also possible to use just {{ main }}. The module will not overwrite existing variables. This means that defining a content region should probably be avoided, as that would have to be displayed with {{ content.content }}.

Warning

This is an experimental module. The approach used might not be a good one, and might cause unforeseen issues. Use at your own risk.