This project is not covered by Drupal’s security advisory policy.
This project adds theme suggestions for nested paragraphs.
When you want to theme a paragraph, it's easy to use a template for that paragraph type. For example, if you have a paragraph type with the machine name of callout, you can create a Twig template called paragraph--callout.html.twig and theme that paragraph type however you wish. Paragraphs can be nested, so it's possible to have a callout paragraph inside another paragraph, for example, a container paragraph. Your normal paragraph--callout.html.twig will apply to all callout paragraphs both inside the container paragraph and outside of it.
But what if you wanted to theme the callout paragraph inside the container paragraph differently than callout paragraph outside of the container paragraph? What's the template name for that?
There isn't one, at least not by default, but this module adds it. In this case, your template would be paragraph--container--callout.html.twig. That's to say, it would start with paragraph (because that's what all paragraph templates start with), and then the parent paragraph name container followed by the nested paragraph name that you want to theme callout. That template would theme the callout paragraph, but only when it's nested within the container paragraph.
Currently, this only goes one parent up, so if you have an image paragraph inside a callout paragraph inside a container paragraph, this will create: paragraph--callout--image.html.twig and paragraph--container--callout.html.twig but not paragraph--container--callout--image.html.twig or paragraph--container--image.html.twig. (Both of these would be easy to add. I just haven't had a use case for them yet.)
Project information
- Created by ochenk on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.