miki-template 1.2.0 → 1.3.3
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.
- package/.github/release-notes/v1.3.1.md +55 -0
- package/CHANGELOG.md +72 -0
- package/README.md +43 -26
- package/assets/banner.png +0 -0
- package/benchmarks/stress.mjs +647 -0
- package/dir/base.html +23 -0
- package/dir/cmpnt.html +11 -0
- package/dir/footer.html +3 -0
- package/dir/home.html +80 -0
- package/dir/navbar.html +9 -0
- package/docs/api.md +20 -3
- package/docs/filters.md +301 -133
- package/docs/partialdef.md +30 -1
- package/docs/tags.md +63 -0
- package/docs/usage.md +50 -3
- package/eslint.config.mjs +9 -1
- package/ex.mjs +33 -0
- package/miki-template-extension/.github/workflows/ci.yml +116 -0
- package/miki-template-extension/.vscodeignore +7 -0
- package/miki-template-extension/CHANGELOG.md +99 -0
- package/miki-template-extension/README.md +244 -53
- package/miki-template-extension/extension.js +1013 -0
- package/miki-template-extension/icon.png +0 -0
- package/miki-template-extension/miki-template-1.7.1.vsix +0 -0
- package/miki-template-extension/package.json +244 -10
- package/miki-template-extension/snippets/miki-template.json +612 -72
- package/miki-template-extension/syntaxes/language-configuration.json +101 -13
- package/miki-template-extension/syntaxes/miki-template.tmLanguage.json +270 -61
- package/miki-template-extension/tests/grammar-tests.json +162 -0
- package/miki-template-extension/tests/run-grammar-tests.js +82 -0
- package/package.json +7 -4
- package/scripts/build-vsix.js +129 -0
- package/scripts/build-vsix.ps1 +15 -0
- package/src/cache.js +41 -2
- package/src/context.js +9 -5
- package/src/context_processors.js +9 -2
- package/src/esm.mjs +12 -0
- package/src/filters.js +472 -24
- package/src/index.js +571 -85
- package/src/lexer.js +76 -54
- package/src/libraries.js +134 -3
- package/src/parser.js +22 -2
- package/src/security.js +4 -2
- package/src/tags/control.js +150 -21
- package/src/tags/extra.js +154 -0
- package/src/tags/i18n.js +49 -23
- package/src/tags/inheritance.js +142 -23
- package/src/tags/util.js +102 -24
- package/tests/esm.test.mjs +37 -2
- package/tests/filters.test.js +155 -0
- package/tests/integration/README.md +32 -0
- package/tests/integration/features.test.cjs +1681 -0
- package/tests/integration/features.test.mjs +1697 -0
- package/tests/integration/templates/base.miki +6 -0
- package/tests/integration/templates/child.miki +6 -0
- package/tests/integration/templates/index.html +17 -0
- package/tests/parser.test.js +5 -3
- package/tests/partialdef.test.js +40 -1
- package/tests/tags.test.js +30 -0
- package/miki-template-1.2.0.vsix +0 -0
|
@@ -1,82 +1,273 @@
|
|
|
1
1
|
# miki-template VS Code Extension
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](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
|
+
---
|
|
4
15
|
|
|
5
16
|
## Features
|
|
6
17
|
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
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 %}`
|
|
11
25
|
|
|
12
|
-
|
|
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
|
|
13
32
|
|
|
14
|
-
|
|
33
|
+
### ⚡ Real-time Validation
|
|
34
|
+
- Unclosed tag detection
|
|
35
|
+
- Mismatched opening/closing tags
|
|
36
|
+
- `{% extends %}` placement validation
|
|
37
|
+
- Performance optimized with debouncing
|
|
15
38
|
|
|
16
|
-
|
|
39
|
+
### 🎨 Color Decorations
|
|
40
|
+
Automatically highlights:
|
|
41
|
+
- `#ff0000`, `#fff`, `#ffffffaa`
|
|
42
|
+
- `rgb()`, `rgba()`
|
|
43
|
+
- `hsl()`, `hsla()`
|
|
17
44
|
|
|
18
|
-
|
|
45
|
+
### 🔧 Code Actions (Quick Fixes)
|
|
46
|
+
- Add missing `{% endif %}`
|
|
47
|
+
- Add missing `{% endfor %}`
|
|
48
|
+
- Wrap selection in `{% block %}`
|
|
49
|
+
- Add `{# prettier-ignore #}`
|
|
19
50
|
|
|
20
|
-
|
|
51
|
+
### 💡 Inlay Hints
|
|
52
|
+
Show inline parameter hints for filter arguments.
|
|
21
53
|
|
|
22
|
-
###
|
|
54
|
+
### 🔗 Bracket Matching Highlights
|
|
55
|
+
Highlight matching `{% if %}` / `{% endif %}` pairs.
|
|
23
56
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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.
|
|
27
99
|
|
|
28
|
-
|
|
100
|
+
---
|
|
29
101
|
|
|
30
|
-
|
|
102
|
+
## Quick Commands
|
|
31
103
|
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
---
|
|
34
137
|
|
|
35
138
|
## File Associations
|
|
36
139
|
|
|
37
|
-
|
|
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
|
|
38
150
|
|
|
39
151
|
```json
|
|
40
152
|
{
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
153
|
+
"[django-html]": {
|
|
154
|
+
"editor.formatOnSave": true,
|
|
155
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
44
156
|
}
|
|
45
157
|
}
|
|
46
158
|
```
|
|
47
159
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
+
---
|
|
79
262
|
|
|
80
263
|
## License
|
|
81
264
|
|
|
82
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
|
+
[](https://www.buymeacoffee.com/alainmiki)
|