Allow declaration of template path in SDC

Created on 29 September 2023, almost 2 years ago
Updated 24 August 2024, 11 months ago

Problem/Motivation

We are planning to rewrite UI Patterns β†’ upon SDC. To achieve this, we are proposing a few changes and additions:

There is already a template property in component definition, but SDC ComponentPluginManager is always overriding its value :

$template = $this->findAsset(
  $component_directory,
  $definition['machineName'],
   'twig'
);
$definition['template'] = basename($template);

We support the statement of "Single Directory Component" where everything related to the component must fit in the same directory. This is the target, this is the good practice to promote.

However, they are real world examples where components in a Drupal theme are using templates from distinct codebase. The upstream codebase has only Twig templates, shared by various PHP app with Twig, and the Drupal theme is adding the Drupal related stuff, including component definitions.

Proposed resolution

We need to keep this property value if already set in YAML and allows the use of twig namespaces.

name:  Card
template: "@upstream_repo/path/to/template.twig"
props: {}
slots: {}

It may be as simple as adding a condition in ComponentPluginManager.

Remaining tasks

If there is a chance for this feature to be accepted, we (UI Patterns team) can propose a merge request soon.

We have one month before the release of Drupal 10.2.0-alpha1.

API changes

Yes, but not breaking.

✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component
single-directory componentsΒ  β†’

Last updated 1 day ago

Created by

πŸ‡«πŸ‡·France pdureau Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024