From 4f900c8311b6acfe474e4e2a3d24560cbfac3771 Mon Sep 17 00:00:00 2001
From: Christoph Burschka <christoph@burschka.de>
Date: Sun, 13 Dec 2015 03:22:41 +0100
Subject: [PATCH] Issue #2630152: Use template namespaces.

Instead of injecting templates into the theme registry,
they should just be loaded via the module namespace.
(This change only affects our reference implementation [list],
as well as the documentation.)
---
 README.md                            | 22 +++++-----------------
 config/install/xbbcode.tag.list.yml  |  2 +-
 templates/list.html.twig             | 13 +++++++++++++
 templates/xbbcode-tag-list.html.twig | 13 -------------
 xbbcode.module                       |  1 -
 5 files changed, 19 insertions(+), 32 deletions(-)
 create mode 100644 templates/list.html.twig
 delete mode 100644 templates/xbbcode-tag-list.html.twig

diff --git a/README.md b/README.md
index 8098a92..e891e9e 100644
--- a/README.md
+++ b/README.md
@@ -47,25 +47,13 @@ template_code: "<span>{{ tag.content }}</span>"
 OR
 
 ```yaml
-# A template file that must be placed in "templates/xbbcode-tag-{id}.html.twig"
-template_file: xbbcode-tag-{id}.html.twig
+# A template file that must be placed in "templates/"
+template_file: @{modulename}/{template}.html.twig
 ```
 
-In the latter case, the template must also be registered with the theme registry
-by implementing `hook_theme()`. Since the template is only used directly, only
-the theme hook is required:
-
-```php
-function {module}_theme() {
-  return [
-    'xbbcode_tag_{id}' => [],
-  ];
-}
-```
-
-Optionally, you may declare
-[CSS/JS libraries](https://www.drupal.org/developing/api/8/assets) defined in
-`*.libraries.yml`) that will be added whenever the tag is rendered:
+Optionally, you may declare [CSS/JS libraries]
+(https://www.drupal.org/developing/api/8/assets) defined in `*.libraries.yml`)
+that will be added whenever the tag is rendered:
 
 ```yaml
 attached:
diff --git a/config/install/xbbcode.tag.list.yml b/config/install/xbbcode.tag.list.yml
index a2dc35f..fe94e65 100644
--- a/config/install/xbbcode.tag.list.yml
+++ b/config/install/xbbcode.tag.list.yml
@@ -7,4 +7,4 @@ sample: |
     [*] One fish
     [*] Two fish
   [/{{ name }}]
-template_file: xbbcode-tag-list.html.twig
\ No newline at end of file
+template_file: @xbbcode/list.html.twig
diff --git a/templates/list.html.twig b/templates/list.html.twig
new file mode 100644
index 0000000..255c74d
--- /dev/null
+++ b/templates/list.html.twig
@@ -0,0 +1,13 @@
+{#
+/**
+ * @file
+ * Render a BBCode list.
+ */
+#}
+{% spaceless %}
+<ul{% if tag.option %} style="list-style-type:{{ tag.option|replace({";":""}) }}"{% endif %}>
+  {% for item in tag.content|split('[*]')|without('0') %}
+    <li>{{ item|trim }}</li>
+  {% endfor %}
+</ul>
+{% endspaceless %}
diff --git a/templates/xbbcode-tag-list.html.twig b/templates/xbbcode-tag-list.html.twig
deleted file mode 100644
index 255c74d..0000000
--- a/templates/xbbcode-tag-list.html.twig
+++ /dev/null
@@ -1,13 +0,0 @@
-{#
-/**
- * @file
- * Render a BBCode list.
- */
-#}
-{% spaceless %}
-<ul{% if tag.option %} style="list-style-type:{{ tag.option|replace({";":""}) }}"{% endif %}>
-  {% for item in tag.content|split('[*]')|without('0') %}
-    <li>{{ item|trim }}</li>
-  {% endfor %}
-</ul>
-{% endspaceless %}
diff --git a/xbbcode.module b/xbbcode.module
index 70ab135..0976487 100644
--- a/xbbcode.module
+++ b/xbbcode.module
@@ -16,7 +16,6 @@ function xbbcode_theme() {
       'render element' => 'fieldset',
       'function' => 'theme_xbbcode_plugin_selection',
     ],
-    'xbbcode_tag_list' => [],
   ];
 }
 
-- 
1.9.1

