A simpler solution to our "keep our templates and component libraries separate" is simply to allow a separate folder from /templates for the component libraries while sharing the Twig namespace.

Twig allows you to specify multiple paths for a Twig namespace. Drupal core only provides the /templates path for a theme's Twig namespace. e.g. bartik/templates is the path for the @bartik Twig namespace.

We could allow theme's to define additional paths for the theme's namespace.

template-paths:
  - components

would mean you can place your Twig templates in /templates or in /components directories.

Alternately, we extend the existing .info syntax:

component-libraries:
  THEMENAME:
    paths:
      - templates
      - components

[edit: we are going with the alternate as it is more consistent.]

Comments

JohnAlbin created an issue. See original summary.

JohnAlbin’s picture

I just discovered that Drupal will find Twig templates no matter what sub-folder they are in. The only advantage of putting them in a /templates folder is that you can reference them using the @THEMENAME Twig namespace.

JohnAlbin’s picture

Issue summary: View changes
JohnAlbin’s picture

Issue summary: View changes

Update the current .info.yml syntax.

JohnAlbin’s picture

Issue summary: View changes
JohnAlbin’s picture

Title: Add ability to extend a theme's namespace » Add ability to extend a theme's or module's namespace

  • JohnAlbin committed d6f3df4 on 8.x-1.x
    Issue #2708103 by JohnAlbin: Add ability to extend a theme's or module's...
JohnAlbin’s picture

Fixed.

JohnAlbin’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.