miki-template 1.2.0 → 1.3.6

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.
Files changed (105) hide show
  1. package/.github/release-notes/v1.3.1.md +55 -0
  2. package/.github/release-notes/v1.3.3.md +77 -0
  3. package/.github/workflows/ci.yml +38 -54
  4. package/.github/workflows/release.yml +106 -0
  5. package/AGENT.md +71 -71
  6. package/API_REFERENCE.md +314 -314
  7. package/CHANGELOG.md +173 -97
  8. package/CODE_OF_CONDUCT.md +14 -14
  9. package/CONTRIBUTING.md +27 -27
  10. package/README.md +342 -304
  11. package/ROADMAP.md +40 -40
  12. package/assets/banner.png +0 -0
  13. package/benchmarks/report.json +16 -16
  14. package/benchmarks/run.js +49 -49
  15. package/benchmarks/stress.mjs +647 -0
  16. package/benchmarks/templates/large.dtpl +7 -7
  17. package/benchmarks/templates/medium.dtpl +3 -3
  18. package/benchmarks/templates/small.dtpl +7 -7
  19. package/context/component.md +109 -109
  20. package/context/prd.md +131 -131
  21. package/context/project-structure.md +33 -33
  22. package/dir/base.html +23 -0
  23. package/dir/cmpnt.html +11 -0
  24. package/dir/footer.html +3 -0
  25. package/dir/home.html +80 -0
  26. package/dir/index.html +80 -0
  27. package/dir/navbar.html +9 -0
  28. package/docs/README.md +18 -18
  29. package/docs/advanced_usage.md +71 -71
  30. package/docs/api.md +119 -102
  31. package/docs/filters.md +708 -540
  32. package/docs/installation.md +106 -106
  33. package/docs/overview.md +57 -57
  34. package/docs/partialdef.md +70 -41
  35. package/docs/security.md +27 -27
  36. package/docs/tags.md +673 -610
  37. package/docs/usage.md +646 -599
  38. package/eslint.config.mjs +42 -34
  39. package/ex.mjs +33 -0
  40. package/miki-template-extension/.github/workflows/ci.yml +116 -0
  41. package/miki-template-extension/.vscodeignore +7 -0
  42. package/miki-template-extension/CHANGELOG.md +99 -0
  43. package/miki-template-extension/LICENSE +21 -21
  44. package/miki-template-extension/README.md +273 -82
  45. package/miki-template-extension/extension.js +1013 -0
  46. package/miki-template-extension/icon.png +0 -0
  47. package/miki-template-extension/icon.svg +10 -10
  48. package/miki-template-extension/miki-template-1.7.1.vsix +0 -0
  49. package/miki-template-extension/package.json +280 -46
  50. package/miki-template-extension/snippets/miki-template.json +717 -177
  51. package/miki-template-extension/syntaxes/language-configuration.json +114 -26
  52. package/miki-template-extension/syntaxes/miki-template.tmLanguage.json +355 -146
  53. package/miki-template-extension/tests/grammar-tests.json +162 -0
  54. package/miki-template-extension/tests/run-grammar-tests.js +82 -0
  55. package/package.json +37 -31
  56. package/sample-app/package-lock.json +901 -0
  57. package/sample-app/package.json +9 -0
  58. package/sample-app/server.js +14 -0
  59. package/sample-app/views/index.html +1 -0
  60. package/scripts/build-vsix.js +129 -0
  61. package/scripts/build-vsix.ps1 +15 -0
  62. package/snippets/miki-template.json +177 -177
  63. package/src/asyncRender.js +20 -20
  64. package/src/cache.js +80 -41
  65. package/src/context.js +126 -122
  66. package/src/context_processors.js +48 -41
  67. package/src/esm.mjs +84 -72
  68. package/src/filters.js +975 -527
  69. package/src/i18n.js +171 -171
  70. package/src/index.js +974 -454
  71. package/src/lexer.js +114 -92
  72. package/src/libraries.js +371 -240
  73. package/src/parser.js +270 -250
  74. package/src/security.js +53 -51
  75. package/src/tags/control.js +719 -590
  76. package/src/tags/extra.js +154 -0
  77. package/src/tags/helpers.js +26 -26
  78. package/src/tags/i18n.js +256 -230
  79. package/src/tags/inheritance.js +335 -216
  80. package/src/tags/registry.js +18 -18
  81. package/src/tags/util.js +400 -322
  82. package/src/types.d.ts +107 -107
  83. package/syntaxes/language-configuration.json +26 -26
  84. package/syntaxes/miki-template.tmLanguage.json +146 -146
  85. package/tests/asyncRender.test.js +17 -17
  86. package/tests/base.html +6 -6
  87. package/tests/child.html +3 -3
  88. package/tests/context_processors.test.js +13 -13
  89. package/tests/esm.test.mjs +61 -26
  90. package/tests/filters.test.js +254 -99
  91. package/tests/include_security.test.js +9 -9
  92. package/tests/integration/README.md +32 -0
  93. package/tests/integration/features.test.cjs +1681 -0
  94. package/tests/integration/features.test.mjs +1697 -0
  95. package/tests/integration/templates/base.miki +6 -0
  96. package/tests/integration/templates/child.miki +6 -0
  97. package/tests/integration/templates/index.html +17 -0
  98. package/tests/lexer.test.js +45 -45
  99. package/tests/parser.test.js +57 -55
  100. package/tests/partial.html +1 -1
  101. package/tests/partialdef.test.js +79 -40
  102. package/tests/production_checks.js +57 -57
  103. package/tests/security.test.js +28 -28
  104. package/tests/tags.test.js +233 -203
  105. package/miki-template-1.2.0.vsix +0 -0
@@ -1,82 +1,273 @@
1
- # miki-template VS Code Extension
2
-
3
- Syntax highlighting, bracket matching, and snippets for [miki-template](https://github.com/alainmiki/miki-template) — a Django-style template engine for Node.js and Express.
4
-
5
- ## Features
6
-
7
- - Syntax highlighting for `.miki` and `.miki-template` files
8
- - Snippets for all built-in tags and common patterns
9
- - Bracket auto-closing for `{% %}`, `{{ }}`, `{# #}`
10
- - Comment toggling with `{# #}`
11
-
12
- ## Supported Tags
13
-
14
- `if / elif / else / endif`, `for / empty / endfor`, `with / endwith`, `cycle`, `comment / endcomment`, `verbatim / endverbatim`, `include`, `extends`, `block / endblock`, `partialdef / endpartialdef`, `partial`, `load`, `templatetag`, `trans`, `blocktrans`, `language / endlanguage`, `widthratio`, `debug`, `autoescape / endautoescape`, `filter / endfilter`, `plural`, `cache / endcache`, `markdown / endmarkdown`, `regroup`, `firstof`, `csrf_token`, `csp_nonce_attr`, `static`, `url`
15
-
16
- ## Supported Filters
17
-
18
- `upper`, `lower`, `title`, `capfirst`, `slugify`, `wordcount`, `striptags`, `linebreaks`, `linebreaksbr`, `truncatewords`, `truncatechars`, `safe`, `escape`, `escapejs`, `length`, `length_is`, `join`, `slice`, `dictsort`, `dictsortreversed`, `first`, `last`, `default`, `default_if_none`, `firstof`, `date`, `time`, `strftime`, `timesince`, `timeuntil`, `add`, `divisibleby`, `floatformat`, `yesno`, `pluralize`, `filesizeformat`, `urlencode`, `escapeuri`, `stringformat`, `cut`, `addslashes`, `removetags`, `trans`, `regroup`, `intcomma`, `intword`, `apnumber`, `ordinal`, `naturalday`, `lorem`
19
-
20
- ## Installation
21
-
22
- ### From VS Code Marketplace
23
-
24
- ```bash
25
- code --install-extension miki-template
26
- ```
27
-
28
- Or search for **miki-template** in the Extensions view (`Ctrl+Shift+X`).
29
-
30
- ### Manual installation
31
-
32
- 1. Copy `syntaxes/` and `snippets/` into your project or user settings
33
- 2. Associate `.miki` files with `miki-template`
34
-
35
- ## File Associations
36
-
37
- Add to your workspace or user `settings.json`:
38
-
39
- ```json
40
- {
41
- "files.associations": {
42
- "*.miki": "miki-template",
43
- "*.miki-template": "miki-template"
44
- }
45
- }
46
- ```
47
-
48
- ## Snippets
49
-
50
- Type any of the following prefixes and press `Tab`:
51
-
52
- | Prefix | Output |
53
- |--------|--------|
54
- | `if` | `{% if %}...{% endif %}` |
55
- | `ifelse` | `{% if %}...{% else %}...{% endif %}` |
56
- | `for` | `{% for %}` with `empty` |
57
- | `block` | `{% block %}` |
58
- | `extends` | `{% extends %}` |
59
- | `include` | `{% include %}` |
60
- | `with` | `{% with %}` |
61
- | `cycle` | `{% cycle %}` |
62
- | `trans` | `{% trans %}` |
63
- | `blocktrans` | `{% blocktrans %}` |
64
- | `language` | `{% language %}` |
65
- | `partialdef` | `{% partialdef %}` |
66
- | `partial` | `{% partial %}` |
67
- | `csrf` | `{% csrf_token %}` |
68
- | `csp` | `{% csp_nonce_attr %}` |
69
- | `static` | `{% static %}` |
70
- | `url` | `{% url %}` |
71
- | `widthratio` | `{% widthratio %}` |
72
- | `debug` | `{% debug %}` |
73
- | `load` | `{% load %}` |
74
- | `comment` | `{# #}` block comment |
75
- | `verbatim` | `{% verbatim %}` |
76
- | `regroup` | `{% for %}` with `regroup` filter |
77
- | `firstof` | `{% firstof %}` |
78
- | `filter` | `{% filter %}` block |
79
-
80
- ## License
81
-
82
- MIT
1
+ # miki-template VS Code Extension
2
+
3
+ [![Buy Me A Coffee](https://img.buymeacoffee.com/button-api/?text=Buy%20me%20a%20coffee&emoji=%E2%98%95&slug=alainmiki&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff)](https://www.buymeacoffee.com/alainmiki)
4
+
5
+ The **ultimate** VS Code extension for **miki-template** and **Django** templates. Packed with features to supercharge your template development.
6
+
7
+ ## Why miki-template?
8
+
9
+ - 100% Django compatible
10
+ - All Django template tags & filters
11
+ - miki-template extensions (partialdef, cache, addtoblock)
12
+ - Works with `.django`, `.dj`, `.miki`, `.miki-template` files
13
+
14
+ ---
15
+
16
+ ## Features
17
+
18
+ ### 🔥 Intelligent Completions
19
+ - **Tags**: All 50+ Django/miki-template tags
20
+ - **Filters**: All 70+ filters with argument hints
21
+ - **forloop.* variables**: Auto-complete when inside for loops
22
+ - **Custom tags/filters**: Auto-detected from project config
23
+ - **Common variables**: user, request, form, items, etc.
24
+ - **Path completions**: Auto-suggest template files for `{% include %}` and `{% extends %}`
25
+
26
+ ### 📖 Hover Documentation
27
+ Hover over any tag or filter to see:
28
+ - Full description
29
+ - Syntax example
30
+ - Argument hints for filters
31
+ - `{{ block.super }}` shows parent block content explanation
32
+
33
+ ### ⚡ Real-time Validation
34
+ - Unclosed tag detection
35
+ - Mismatched opening/closing tags
36
+ - `{% extends %}` placement validation
37
+ - Performance optimized with debouncing
38
+
39
+ ### 🎨 Color Decorations
40
+ Automatically highlights:
41
+ - `#ff0000`, `#fff`, `#ffffffaa`
42
+ - `rgb()`, `rgba()`
43
+ - `hsl()`, `hsla()`
44
+
45
+ ### 🔧 Code Actions (Quick Fixes)
46
+ - Add missing `{% endif %}`
47
+ - Add missing `{% endfor %}`
48
+ - Wrap selection in `{% block %}`
49
+ - Add `{# prettier-ignore #}`
50
+
51
+ ### 💡 Inlay Hints
52
+ Show inline parameter hints for filter arguments.
53
+
54
+ ### 🔗 Bracket Matching Highlights
55
+ Highlight matching `{% if %}` / `{% endif %}` pairs.
56
+
57
+ ### 🚀 Go-to-Definition
58
+ Jump to:
59
+ - `{% include "file" %}`
60
+ - `{% extends "file" %}`
61
+ - `{% block name %}`
62
+ - `{% partialdef name %}`
63
+
64
+ ### 🔍 Project-wide Find References
65
+ Find all references to:
66
+ - Block definitions across workspace
67
+ - Included templates
68
+ - Extended templates
69
+
70
+ ### 📋 Smart Tag Selection
71
+ Double-click to select entire `{% block %}` content.
72
+
73
+ ### 🎯 Quick Outline Navigation
74
+ Jump between blocks with keyboard shortcuts.
75
+
76
+ ### 📝 Template Preview
77
+ Preview template syntax in a new tab.
78
+
79
+ ### ✏️ Rename Blocks (F2)
80
+ Rename any `{% block name %}` and automatically update all `{{ block.name }}` references across your entire workspace. Just place cursor on a block name and press F2.
81
+
82
+ ### 🎨 Semantic Highlighting
83
+ Enhanced syntax highlighting using VS Code's Semantic Token API for better theme support and more accurate token classification.
84
+
85
+ ### 🌐 HTML/CSS/JS Support
86
+ Full embedded language support for:
87
+ - **HTML**: Proper tag and attribute highlighting
88
+ - **CSS**: Syntax highlighting in `<style>` tags
89
+ - **JavaScript**: Syntax highlighting in `<script>` tags
90
+ - **Emmet**: Full Emmet abbreviation support for HTML and JavaScript
91
+ - **Auto-closing**: HTML tags, brackets, and quotes
92
+ - **Bracket matching**: HTML tags, parentheses, brackets
93
+
94
+ ### 📋 Smart Paste
95
+ Paste HTML content and the extension will automatically append `|safe` filter to prevent escaping issues.
96
+
97
+ ### 🔧 Code Actions
98
+ Quick fixes for common issues.
99
+
100
+ ---
101
+
102
+ ## Quick Commands
103
+
104
+ | Command | Description | Shortcut |
105
+ |---------|-------------|----------|
106
+ | `insertFilter` | Wrap with filter | `Ctrl+Shift+F` |
107
+ | `wrapInBlock` | Wrap in block | - |
108
+ | `wrapInFor` | Wrap in for loop | - |
109
+ | `wrapInIf` | Wrap in if condition | - |
110
+ | `addPrettierIgnore` | Add prettier ignore | - |
111
+ | `goToNextBlock` | Next block | `Ctrl+Shift+.` |
112
+ | `goToPrevBlock` | Previous block | `Ctrl+Shift+,` |
113
+ | `previewTemplate` | Preview template | - |
114
+ | `showOutline` | Show outline | - |
115
+ | `findBlockReferences` | Find block refs | - |
116
+ | `validateAll` | Validate all | - |
117
+
118
+ > **Tip:** Press `F2` on any block name to rename it across the workspace!
119
+
120
+ ---
121
+
122
+ ## Settings
123
+
124
+ | Setting | Default | Description |
125
+ |---------|---------|-------------|
126
+ | `enableValidation` | `true` | Enable validation |
127
+ | `enableCompletions` | `true` | Enable completions |
128
+ | `enableHover` | `true` | Enable hover docs |
129
+ | `enableColorDecorations` | `true` | Highlight colors |
130
+ | `enableCodeActions` | `true` | Enable quick fixes |
131
+ | `enableInlayHints` | `true` | Show inlay hints |
132
+ | `enableBracketHighlight` | `true` | Highlight brackets |
133
+ | `enableSmartPaste` | `true` | Smart paste handling |
134
+ | `formatOnSave` | `false` | Format on save |
135
+
136
+ ---
137
+
138
+ ## File Associations
139
+
140
+ | Extension | Language |
141
+ |-----------|----------|
142
+ | `.miki` | miki-template |
143
+ | `.miki-template` | miki-template |
144
+ | `.django` | Django HTML |
145
+ | `.dj` | Django HTML |
146
+
147
+ ---
148
+
149
+ ## Format on Save
150
+
151
+ ```json
152
+ {
153
+ "[django-html]": {
154
+ "editor.formatOnSave": true,
155
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
156
+ }
157
+ }
158
+ ```
159
+
160
+ ---
161
+
162
+ ## Custom Tags/Filters Detection
163
+
164
+ The extension auto-detects custom tags and filters from:
165
+ - `miki-template.config.js`
166
+ - `miki-template.config.json`
167
+ - `.mikirc`
168
+ - `package.json`
169
+
170
+ ```javascript
171
+ // miki-template.config.js
172
+ module.exports = {
173
+ filters: ['myFilter', 'customFilter'],
174
+ tags: ['myTag', 'customTag']
175
+ };
176
+ ```
177
+
178
+ ---
179
+
180
+ ## Path Completions
181
+
182
+ When typing `{% include %}` or `{% extends %}`, the extension automatically suggests template files from your workspace:
183
+
184
+ ```html
185
+ {% include "partials/" ← Shows all template files
186
+ {% extends "base" ← Shows matching templates
187
+ ```
188
+
189
+ Files are searched recursively throughout your workspace and filtered as you type.
190
+
191
+ ---
192
+
193
+ ## Examples
194
+
195
+ ### Basic Template
196
+ ```html
197
+ {% extends "base.html" %}
198
+
199
+ {% block content %}
200
+ <h1>{{ title|default:"Welcome" }}</h1>
201
+
202
+ {% if user.is_authenticated %}
203
+ <p>Hello, {{ user.name }}!</p>
204
+ {% else %}
205
+ <p>Please log in.</p>
206
+ {% endif %}
207
+
208
+ {% for item in items %}
209
+ <li>{{ forloop.counter }}. {{ item }}</li>
210
+ {% empty %}
211
+ <li>No items found.</li>
212
+ {% endfor %}
213
+ {% endblock %}
214
+ ```
215
+
216
+ ### Rename Blocks
217
+ Place cursor on any `{% block name %}` and press `F2`:
218
+
219
+ ```html
220
+ <!-- Before rename: block title → block heading -->
221
+ {% block title %}Welcome{% endblock %}
222
+ {{ block.title }}
223
+
224
+ <!-- After pressing F2 and entering "heading": -->
225
+ {% block heading %}Welcome{% endblock %}
226
+ {{ block.heading }}
227
+ ```
228
+
229
+ All references across the workspace are updated automatically.
230
+
231
+ ### With Partial
232
+ ```html
233
+ {% partialdef card inline %}
234
+ <div class="card">
235
+ <h3>{{ title }}</h3>
236
+ <p>{{ description }}</p>
237
+ </div>
238
+ {% endpartialdef %}
239
+
240
+ {% partial card with title="Hello" %}
241
+ ```
242
+
243
+ ---
244
+
245
+ ## Development
246
+
247
+ ```bash
248
+ # Install dependencies
249
+ npm install
250
+
251
+ # Run tests
252
+ npm test
253
+
254
+ # Package
255
+ npm run package
256
+
257
+ # Watch & install
258
+ npm run watch
259
+ ```
260
+
261
+ ---
262
+
263
+ ## License
264
+
265
+ MIT
266
+
267
+ ---
268
+
269
+ ## Support
270
+
271
+ If this extension helps you, consider [buying me a coffee](https://www.buymeacoffee.com/alainmiki)!
272
+
273
+ [![Buy Me A Coffee](https://img.buymeacoffee.com/button-api/?text=Buy%20me%20a%20coffee&emoji=%E2%98%95&slug=alainmiki&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff)](https://www.buymeacoffee.com/alainmiki)