md2x 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,35 @@
1
+ <div class="md2x-html-example">
2
+ <div class="my-component">Hello md2x! This is html template</div>
3
+ <div class="items"></div>
4
+
5
+ <script>
6
+ (() => {
7
+ const root = document.currentScript && document.currentScript.parentElement;
8
+ if (!root) return;
9
+
10
+ const data = templateData;
11
+ const items = root.querySelector('.items');
12
+ if (!items) return;
13
+
14
+ // Render a simple list: [{ title, message }, ...]
15
+ items.textContent = '';
16
+ const arr = Array.isArray(data) ? data : (data != null ? [data] : []);
17
+ for (let i = 0; i < arr.length; i++) {
18
+ const item = arr[i] || {};
19
+ const h2 = document.createElement('h2');
20
+ h2.textContent = item.title != null ? String(item.title) : '';
21
+ const p = document.createElement('p');
22
+ p.textContent = item.message != null ? String(item.message) : '';
23
+ items.appendChild(h2);
24
+ items.appendChild(p);
25
+ }
26
+ })();
27
+ </script>
28
+
29
+ <style>
30
+ .md2x-html-example .my-component {
31
+ color: red;
32
+ }
33
+ </style>
34
+ </div>
35
+