If a module declares a tag with a template file, it currently needs to take care of registering that file with hook_theme().

This isn't technically necessary - as long as we can make sure that XBBCode's hook_theme() is invoked whenever a template tag is added, we can register those template files in xbbcode itself.

Comments

cburschka created an issue. See original summary.

cburschka’s picture

Not that easy, unfortunately. The theme registry does, in fact, want the template file to be in the templates/ folder of the module whose hook_theme() declares the hook.

Needs some more thought.

cburschka’s picture

Going through the theme registry is a hack in the first place, because Drupal has a perfectly serviceable file-system loader.

Templates can be loaded as '@module/name.html.twig'.

For flexibility (because tags are entities that don't implicitly belong to a module), it would be best to require modules to explicitly name the namespace. This also means our internals don't change at all - it's purely a change to the documentation and to the sample implementation (the [list] tag).

cburschka’s picture

Status: Active » Needs review
StatusFileSize
new3.53 KB
cburschka’s picture

Title: Automatically register tag template files » Use module namespaces for templates.
cburschka’s picture

Status: Needs review » Fixed

And done.

  • cburschka committed 4f900c8 on 8.x-3.x
    Issue #2630152: Use template namespaces.
    
    Instead of injecting templates...

Status: Fixed » Closed (fixed)

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