Closed (works as designed)
Project:
Components!
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
12 Dec 2016 at 10:45 UTC
Updated:
19 Sep 2019 at 08:13 UTC
Jump to comment: Most recent
Comments
Comment #2
aleksipThis isn't used only for multiple component libraries, it can also be used to create multiple Twig namespaces for a single component library.
E.g. in themes that integrate with Pattern Lab the
component-librarieskey can be something like this:This is extremely useful as Pattern Lab supports these namespaces as well.
Comment #3
wim leersWhy not just use those as a directory structure? Why do they have to be namespaces? Them being namespaces results in conflicts when using subthemes.
Comment #4
aleksipDefining a root namespace and then using
@root/00-atoms,@root/01-moleculesetc. would work too, I guess. It is just that Pattern Lab supports these namespaces 'out of the box', and also that PL supports a number prefix for ordering (which can be changed without breaking anything in PL), and this is circumvented by the namespaces.Ideally the same component library could be used in a Drupal theme and e.g. a Symfony bundle. Stuff like theme inheritance does complicate things, but it would be great to be able to keep component libraries as decoupled as possible, and to force as few Drupal related restrictions as possible. But I guess some restrictions are unavoidable.
Comment #5
justclint commentedDisregard my post. I realized I was accessing the incorrect directory.
Comment #6
johnalbinIt's unlikely a theme will ever need multiple "component libraries". But that's not the same thing as wanting multiple Twig namespaces.
There was no technical reason to limit the number of Twig namespaces. And I think aleksip explains their reasoning well in the above comments.
For myself, recently, I let Drupal define the
@[theme name]Twig namespace that points at theTHEME/templatesdirectory and let this module define a@componentsTwig namespace that points at theTHEME/componentsdirectory.Drupal doesn't need to be aware. This module just makes it possible to talk to Drupal's instance of Twig. Twig does need to know about the namespaces, obviously.
You totally can. And then you don't need this module.
You're not required to redefine the theme's default namespace.
I moved away from using one namespace with mulitiple directories. Twig still supports this, so the module will too.