I've created a custom module that creates a jumbotron custom block type. The module has an empty .module file and a dir config/install with many .yml files. This works great when I install and create blocks. I can even place my block--bundle--jumbotron.html.twig in the templates folder of the theme and styling works great! I would like this twig file included in the module and many tutorials explain how to do this if you have a build function in your module, I do not. The module is just creating a block type for me.
1 Answer
Create a theme hook with the template name by replacing dashes with underscores:
mymodule.module:
/**
* Implements hook_theme().
*/
function mymodule_theme() {
return [
'block__bundle__jumbotron' => [
'render element' => 'elements',
'base hook' => 'block',
],
];
}
templates
sub-folder in your module directory?'block__bundle__jumbotron'