I'm trying to write my first module on Drupal 8. It's a module that deal with paragraphs.

I need to add some template suggestion to paragraphs and declare them in my module /template folder.

So I defined a

function paragraphs_builder_theme_suggestions_paragraph_alter(array &$suggestions, array $variables) {
  $suggestions[] = 'paragraph__builder';

It works well when I define paragraph--builder.html.twig file in my theme, but I need to define that file in my module because I want my module to be theme independent.

When I define the paragraph--builder.html.twig file in the template folder of my module (removed the one in my theme first), the file is not red (I have some debug in that file that does not trigger). I tried to clean cache, everything... without success.

It seems that unlike Drupal 7, Drupal 8 only read the theme folder to find the template files that could overwrite default ones.

So my question is, how could I define my template file in a module ?

Thank you




Browse other questions tagged or ask your own question.