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.
Files changed (60) hide show
  1. package/.github/release-notes/v1.3.1.md +55 -0
  2. package/CHANGELOG.md +72 -0
  3. package/README.md +43 -26
  4. package/assets/banner.png +0 -0
  5. package/benchmarks/stress.mjs +647 -0
  6. package/dir/base.html +23 -0
  7. package/dir/cmpnt.html +11 -0
  8. package/dir/footer.html +3 -0
  9. package/dir/home.html +80 -0
  10. package/dir/navbar.html +9 -0
  11. package/docs/api.md +20 -3
  12. package/docs/filters.md +301 -133
  13. package/docs/partialdef.md +30 -1
  14. package/docs/tags.md +63 -0
  15. package/docs/usage.md +50 -3
  16. package/eslint.config.mjs +9 -1
  17. package/ex.mjs +33 -0
  18. package/miki-template-extension/.github/workflows/ci.yml +116 -0
  19. package/miki-template-extension/.vscodeignore +7 -0
  20. package/miki-template-extension/CHANGELOG.md +99 -0
  21. package/miki-template-extension/README.md +244 -53
  22. package/miki-template-extension/extension.js +1013 -0
  23. package/miki-template-extension/icon.png +0 -0
  24. package/miki-template-extension/miki-template-1.7.1.vsix +0 -0
  25. package/miki-template-extension/package.json +244 -10
  26. package/miki-template-extension/snippets/miki-template.json +612 -72
  27. package/miki-template-extension/syntaxes/language-configuration.json +101 -13
  28. package/miki-template-extension/syntaxes/miki-template.tmLanguage.json +270 -61
  29. package/miki-template-extension/tests/grammar-tests.json +162 -0
  30. package/miki-template-extension/tests/run-grammar-tests.js +82 -0
  31. package/package.json +7 -4
  32. package/scripts/build-vsix.js +129 -0
  33. package/scripts/build-vsix.ps1 +15 -0
  34. package/src/cache.js +41 -2
  35. package/src/context.js +9 -5
  36. package/src/context_processors.js +9 -2
  37. package/src/esm.mjs +12 -0
  38. package/src/filters.js +472 -24
  39. package/src/index.js +571 -85
  40. package/src/lexer.js +76 -54
  41. package/src/libraries.js +134 -3
  42. package/src/parser.js +22 -2
  43. package/src/security.js +4 -2
  44. package/src/tags/control.js +150 -21
  45. package/src/tags/extra.js +154 -0
  46. package/src/tags/i18n.js +49 -23
  47. package/src/tags/inheritance.js +142 -23
  48. package/src/tags/util.js +102 -24
  49. package/tests/esm.test.mjs +37 -2
  50. package/tests/filters.test.js +155 -0
  51. package/tests/integration/README.md +32 -0
  52. package/tests/integration/features.test.cjs +1681 -0
  53. package/tests/integration/features.test.mjs +1697 -0
  54. package/tests/integration/templates/base.miki +6 -0
  55. package/tests/integration/templates/child.miki +6 -0
  56. package/tests/integration/templates/index.html +17 -0
  57. package/tests/parser.test.js +5 -3
  58. package/tests/partialdef.test.js +40 -1
  59. package/tests/tags.test.js +30 -0
  60. package/miki-template-1.2.0.vsix +0 -0
@@ -1,114 +1,337 @@
1
1
  {
2
- "miki-template": {
2
+ "meta": {
3
+ "name": "miki-template",
4
+ "description": "Comprehensive snippets for miki-template and Django templates"
5
+ },
6
+ "snippets": {
3
7
  "if": {
4
8
  "prefix": "if",
5
9
  "body": [
6
10
  "{% if ${1:condition} %}",
7
- " ${2:content}",
11
+ " $2",
8
12
  "{% endif %}"
9
13
  ],
10
14
  "description": "If block"
11
15
  },
16
+ "ifelif": {
17
+ "prefix": "ifelif",
18
+ "body": [
19
+ "{% if ${1:condition} %}",
20
+ " $2",
21
+ "{% elif ${3:condition} %}",
22
+ " $4",
23
+ "{% endif %}"
24
+ ],
25
+ "description": "If/elif block"
26
+ },
12
27
  "ifelse": {
13
28
  "prefix": "ifelse",
14
29
  "body": [
15
30
  "{% if ${1:condition} %}",
16
- " ${2:content}",
31
+ " $2",
17
32
  "{% else %}",
18
- " ${3:fallback}",
33
+ " $3",
19
34
  "{% endif %}"
20
35
  ],
21
36
  "description": "If/else block"
22
37
  },
38
+ "ifelifelse": {
39
+ "prefix": "ifelifelse",
40
+ "body": [
41
+ "{% if ${1:condition} %}",
42
+ " $2",
43
+ "{% elif ${3:condition} %}",
44
+ " $4",
45
+ "{% else %}",
46
+ " $5",
47
+ "{% endif %}"
48
+ ],
49
+ "description": "If/elif/else block"
50
+ },
23
51
  "for": {
24
52
  "prefix": "for",
25
53
  "body": [
26
54
  "{% for ${1:item} in ${2:items} %}",
27
- " ${3:{{ ${1} }}}",
55
+ " $3",
28
56
  "{% empty %}",
29
- " ${4:No items}",
57
+ " $4",
58
+ "{% endfor %}"
59
+ ],
60
+ "description": "For loop with empty"
61
+ },
62
+ "for-simple": {
63
+ "prefix": "for-simple",
64
+ "body": [
65
+ "{% for ${1:item} in ${2:items} %}",
66
+ " $3",
67
+ "{% endfor %}"
68
+ ],
69
+ "description": "Simple for loop"
70
+ },
71
+ "forloop-counter": {
72
+ "prefix": "forloop",
73
+ "body": [
74
+ "{% for ${1:item} in ${2:items} %}",
75
+ " {{ forloop.counter }}. ${1}",
30
76
  "{% endfor %}"
31
77
  ],
32
- "description": "For loop"
78
+ "description": "For loop with forloop.counter"
79
+ },
80
+ "forloop-nested": {
81
+ "prefix": "forloop-nested",
82
+ "body": [
83
+ "{% for ${1:outer} in ${2:outers %}",
84
+ " {% for ${3:inner} in ${4:inners} %}",
85
+ " {{ forloop.parentloop.counter }}.{{ forloop.counter }}: {{ ${3} }}",
86
+ " {% endfor %}",
87
+ "{% endfor %}"
88
+ ],
89
+ "description": "Nested for loops with parentloop"
90
+ },
91
+ "for-unpack": {
92
+ "prefix": "for-unpack",
93
+ "body": [
94
+ "{% for ${1:key}, ${2:value} in ${3:dict} %}",
95
+ " {{ ${1} }}: {{ ${2} }}",
96
+ "{% endfor %}"
97
+ ],
98
+ "description": "For loop with tuple unpacking"
99
+ },
100
+ "with": {
101
+ "prefix": "with",
102
+ "body": [
103
+ "{% with ${1:var} as ${2:alias} %}",
104
+ " $3",
105
+ "{% endwith %}"
106
+ ],
107
+ "description": "With block"
108
+ },
109
+ "with-multi": {
110
+ "prefix": "with-multi",
111
+ "body": [
112
+ "{% with ${1:var1}=${2:value1} ${3:var2}=${4:value2} %}",
113
+ " $5",
114
+ "{% endwith %}"
115
+ ],
116
+ "description": "With multiple variables"
117
+ },
118
+ "cycle": {
119
+ "prefix": "cycle",
120
+ "body": "{% cycle '${1:odd}' '${2:even}' %}",
121
+ "description": "Cycle between values"
122
+ },
123
+ "cycle-named": {
124
+ "prefix": "cycle-named",
125
+ "body": "{% cycle '${1:odd}' '${2:even}' as ${3:marker} silent %}",
126
+ "description": "Named cycle with state"
127
+ },
128
+ "firstof": {
129
+ "prefix": "firstof",
130
+ "body": "{% firstof ${1:var1} ${2:var2} \"${3:fallback}\" %}",
131
+ "description": "First truthy value"
132
+ },
133
+ "comment": {
134
+ "prefix": "comment",
135
+ "body": [
136
+ "{% comment %}",
137
+ " $1",
138
+ "{% endcomment %}"
139
+ ],
140
+ "description": "Comment block"
141
+ },
142
+ "comment-inline": {
143
+ "prefix": "comment-inline",
144
+ "body": "{% comment %}$1{% endcomment %}",
145
+ "description": "Inline comment"
146
+ },
147
+ "verbatim": {
148
+ "prefix": "verbatim",
149
+ "body": [
150
+ "{% verbatim %}",
151
+ " $1",
152
+ "{% endverbatim %}"
153
+ ],
154
+ "description": "Raw content (no parsing)"
155
+ },
156
+ "spaceless": {
157
+ "prefix": "spaceless",
158
+ "body": [
159
+ "{% spaceless %}",
160
+ " $1",
161
+ "{% endspaceless %}"
162
+ ],
163
+ "description": "Remove whitespace"
164
+ },
165
+ "autoescape": {
166
+ "prefix": "autoescape",
167
+ "body": [
168
+ "{% autoescape ${1:on} %}",
169
+ " $2",
170
+ "{% endautoescape %}"
171
+ ],
172
+ "description": "Autoescape block"
33
173
  },
34
174
  "block": {
35
175
  "prefix": "block",
36
176
  "body": [
37
177
  "{% block ${1:name} %}",
38
- " ${2:content}",
178
+ " $2",
39
179
  "{% endblock %}"
40
180
  ],
41
181
  "description": "Block definition"
42
182
  },
183
+ "block-super": {
184
+ "prefix": "block-super",
185
+ "body": [
186
+ "{% block ${1:name} %}",
187
+ " {{ block.super }}",
188
+ " $2",
189
+ "{% endblock %}"
190
+ ],
191
+ "description": "Block with block.super"
192
+ },
43
193
  "extends": {
44
194
  "prefix": "extends",
45
195
  "body": "{% extends \"${1:base.html}\" %}",
46
- "description": "Extends parent template"
196
+ "description": "Extend parent template"
47
197
  },
48
198
  "include": {
49
199
  "prefix": "include",
50
- "body": "{% include \"${1:header.html}\" %}",
200
+ "body": "{% include \"${1:template.html}\" %}",
51
201
  "description": "Include template"
52
202
  },
53
- "with": {
54
- "prefix": "with",
203
+ "include-with": {
204
+ "prefix": "include-with",
205
+ "body": "{% include \"${1:template.html}\" with ${2:var}=${3:value} %}",
206
+ "description": "Include with context"
207
+ },
208
+ "include-only": {
209
+ "prefix": "include-only",
210
+ "body": "{% include \"${1:template.html}\" only %}",
211
+ "description": "Include without context"
212
+ },
213
+ "partialdef": {
214
+ "prefix": "partialdef",
55
215
  "body": [
56
- "{% with ${1:var} as ${2:alias} %}",
57
- " ${3:{{ ${2} }}}",
58
- "{% endwith %}"
216
+ "{% partialdef ${1:name} %}",
217
+ " $2",
218
+ "{% endpartialdef %}"
59
219
  ],
60
- "description": "With block"
220
+ "description": "Define partial template"
61
221
  },
62
- "cycle": {
63
- "prefix": "cycle",
64
- "body": "{% cycle '${1:odd}' '${2:even}' %}",
65
- "description": "Cycle tag"
222
+ "partialdef-inline": {
223
+ "prefix": "partialdef-inline",
224
+ "body": [
225
+ "{% partialdef ${1:name} inline %}",
226
+ " $2",
227
+ "{% endpartialdef %}"
228
+ ],
229
+ "description": "Define inline partial"
230
+ },
231
+ "partialdef-lazy": {
232
+ "prefix": "partialdef-lazy",
233
+ "body": [
234
+ "{% partialdef ${1:name} lazy %}",
235
+ " $2",
236
+ "{% endpartialdef %}"
237
+ ],
238
+ "description": "Define lazy partial"
239
+ },
240
+ "partial": {
241
+ "prefix": "partial",
242
+ "body": "{% partial ${1:name} %}",
243
+ "description": "Render partial"
244
+ },
245
+ "partial-with": {
246
+ "prefix": "partial-with",
247
+ "body": "{% partial ${1:name} with ${2:var}=${3:value} %}",
248
+ "description": "Render partial with context"
249
+ },
250
+ "load": {
251
+ "prefix": "load",
252
+ "body": "{% load ${1:i18n} %}",
253
+ "description": "Load tag library"
66
254
  },
67
255
  "trans": {
68
256
  "prefix": "trans",
69
257
  "body": "{% trans \"${1:Hello, World!}\" %}",
70
258
  "description": "Translate string"
71
259
  },
260
+ "trans-var": {
261
+ "prefix": "trans-var",
262
+ "body": "{% trans \"${1:Hello, %s!}\" ${2:var} %}",
263
+ "description": "Translate with variable"
264
+ },
72
265
  "blocktrans": {
73
266
  "prefix": "blocktrans",
74
267
  "body": [
75
- "{% blocktrans with ${1:name}=${2:user.name} %}",
76
- " ${3:Hello {{ ${1} }}}",
268
+ "{% blocktrans with ${1:name}=${2:value} %}",
269
+ " $3",
77
270
  "{% endblocktrans %}"
78
271
  ],
79
272
  "description": "Translate block"
80
273
  },
274
+ "blocktrans-plural": {
275
+ "prefix": "blocktrans-plural",
276
+ "body": [
277
+ "{% blocktrans with ${1:name}=${2:value} count ${3:n}=${4:items|length %}",
278
+ " {{ name }} has {{ ${3} }} item.",
279
+ "{% plural %}",
280
+ " {{ name }} has {{ ${3} }} items.",
281
+ "{% endblocktrans %}"
282
+ ],
283
+ "description": "Translate block with plural"
284
+ },
81
285
  "language": {
82
286
  "prefix": "language",
83
287
  "body": [
84
288
  "{% language \"${1:fr}\" %}",
85
- " ${2}",
289
+ " $2",
86
290
  "{% endlanguage %}"
87
291
  ],
88
292
  "description": "Switch language"
89
293
  },
90
- "partialdef": {
91
- "prefix": "partialdef",
294
+ "regroup": {
295
+ "prefix": "regroup",
92
296
  "body": [
93
- "{% partialdef ${1:name} %}",
94
- " ${2}",
95
- "{% endpartialdef %}"
297
+ "{% regroup ${1:items} by ${2:attribute} as ${3:groups} %}",
298
+ "{% for ${4:group} in ${3} %}",
299
+ " <h3>{{ ${4}.grouper }}</h3>",
300
+ "{% endfor %}"
96
301
  ],
97
- "description": "Define partial"
302
+ "description": "Regroup by attribute"
98
303
  },
99
- "partial": {
100
- "prefix": "partial",
101
- "body": "{% partial ${1:name} %}",
102
- "description": "Render partial"
304
+ "cache": {
305
+ "prefix": "cache",
306
+ "body": [
307
+ "{% cache ${1:timeout} ${2:key} %}",
308
+ " $3",
309
+ "{% endcache %}"
310
+ ],
311
+ "description": "Cache block"
312
+ },
313
+ "filter-block": {
314
+ "prefix": "filter-block",
315
+ "body": [
316
+ "{% filter ${1:lower} %}",
317
+ " $2",
318
+ "{% endfilter %}"
319
+ ],
320
+ "description": "Filter block"
321
+ },
322
+ "widthratio": {
323
+ "prefix": "widthratio",
324
+ "body": "{% widthratio ${1:value} ${2:max} ${3:max_width} %}",
325
+ "description": "Proportional width"
103
326
  },
104
327
  "csrf": {
105
328
  "prefix": "csrf",
106
329
  "body": "{% csrf_token %}",
107
- "description": "CSRF token input"
330
+ "description": "CSRF token"
108
331
  },
109
332
  "csp": {
110
333
  "prefix": "csp",
111
- "body": "<script {% csp_nonce_attr %}></script>",
334
+ "body": "<script {% csp_nonce_attr %}>$1</script>",
112
335
  "description": "CSP nonce attribute"
113
336
  },
114
337
  "static": {
@@ -118,60 +341,377 @@
118
341
  },
119
342
  "url": {
120
343
  "prefix": "url",
121
- "body": "{% url \"${1:route_name}\" ${2:args} %}",
122
- "description": "URL for named route"
344
+ "body": "{% url \"${1:route}\" %}",
345
+ "description": "URL by name"
123
346
  },
124
- "widthratio": {
125
- "prefix": "widthratio",
126
- "body": "{% widthratio ${1:value} ${2:max} ${3:max_width} %}",
127
- "description": "Proportional width"
347
+ "url-args": {
348
+ "prefix": "url-args",
349
+ "body": "{% url \"${1:route}\" ${2:arg1} ${3:arg2} %}",
350
+ "description": "URL with positional args"
351
+ },
352
+ "url-kwargs": {
353
+ "prefix": "url-kwargs",
354
+ "body": "{% url \"${1:route}\" ${2:key}=${3:value} %}",
355
+ "description": "URL with keyword args"
128
356
  },
129
357
  "debug": {
130
358
  "prefix": "debug",
131
359
  "body": "{% debug %}",
132
- "description": "Dump template context"
360
+ "description": "Debug output"
133
361
  },
134
- "load": {
135
- "prefix": "load",
136
- "body": "{% load ${1:i18n} %}",
137
- "description": "Load tag library"
362
+ "templatetag": {
363
+ "prefix": "templatetag",
364
+ "body": "{% templatetag ${1|openblock|closeblock|openvariable|closevariable|openbrace|closebrace|opencomment|closecomment} %}",
365
+ "description": "Render template tag symbol"
138
366
  },
139
- "comment": {
140
- "prefix": "comment",
367
+ "addtoblock": {
368
+ "prefix": "addtoblock",
141
369
  "body": [
142
- "{#",
143
- " ${1:comment}",
144
- "#}"
370
+ "{% addtoblock ${1:css %}",
371
+ " $2",
372
+ "{% endaddtoblock %}"
145
373
  ],
146
- "description": "Comment block"
374
+ "description": "Add content to block"
147
375
  },
148
- "verbatim": {
149
- "prefix": "verbatim",
376
+ "prettier-ignore": {
377
+ "prefix": "prettier-ignore",
378
+ "body": "{# prettier-ignore #}",
379
+ "description": "Prettier ignore (single line)"
380
+ },
381
+ "prettier-ignore-start": {
382
+ "prefix": "prettier-ignore-start",
150
383
  "body": [
151
- "{% verbatim %}",
152
- " ${1}",
153
- "{% endverbatim %}"
384
+ "{# prettier-ignore-start #}",
385
+ "$1",
386
+ "{# prettier-ignore-end #}"
154
387
  ],
155
- "description": "Verbatim block"
388
+ "description": "Prettier ignore region"
156
389
  },
157
- "regroup": {
158
- "prefix": "regroup",
159
- "body": "{% for ${1:group} in ${2:items}|regroup:\"${3:category}\" %}{{ ${1}.grouper }}{% endfor %}",
160
- "description": "Regroup by attribute"
390
+ "filter-upper": {
391
+ "prefix": "upper",
392
+ "body": "{{ ${1:value}|upper }}",
393
+ "description": "Convert to uppercase"
161
394
  },
162
- "firstof": {
163
- "prefix": "firstof",
164
- "body": "{% firstof ${1:var1} ${2:var2} \"${3:fallback}\" %}",
165
- "description": "First truthy value"
395
+ "filter-lower": {
396
+ "prefix": "lower",
397
+ "body": "{{ ${1:value}|lower }}",
398
+ "description": "Convert to lowercase"
399
+ },
400
+ "filter-title": {
401
+ "prefix": "title",
402
+ "body": "{{ ${1:value}|title }}",
403
+ "description": "Title case"
404
+ },
405
+ "filter-capfirst": {
406
+ "prefix": "capfirst",
407
+ "body": "{{ ${1:value}|capfirst }}",
408
+ "description": "Capitalize first letter"
409
+ },
410
+ "filter-default": {
411
+ "prefix": "default",
412
+ "body": "{{ ${1:value}|default:\"${2:fallback}\" }}",
413
+ "description": "Default value if falsy"
414
+ },
415
+ "filter-default-if-none": {
416
+ "prefix": "default_if_none",
417
+ "body": "{{ ${1:value}|default_if_none:\"${2:fallback}\" }}",
418
+ "description": "Default if None/undefined"
419
+ },
420
+ "filter-length": {
421
+ "prefix": "length",
422
+ "body": "{{ ${1:value}|length }}",
423
+ "description": "Length of value"
424
+ },
425
+ "filter-slice": {
426
+ "prefix": "slice",
427
+ "body": "{{ ${1:value}|slice:\"${2:0:3}\" }}",
428
+ "description": "Slice array/string"
429
+ },
430
+ "filter-join": {
431
+ "prefix": "join",
432
+ "body": "{{ ${1:list}|join:\"${2:, }\" }}",
433
+ "description": "Join array elements"
434
+ },
435
+ "filter-first": {
436
+ "prefix": "first",
437
+ "body": "{{ ${1:list}|first }}",
438
+ "description": "First element"
439
+ },
440
+ "filter-last": {
441
+ "prefix": "last",
442
+ "body": "{{ ${1:list}|last }}",
443
+ "description": "Last element"
444
+ },
445
+ "filter-truncatewords": {
446
+ "prefix": "truncatewords",
447
+ "body": "{{ ${1:text}|truncatewords:${2:10} }}",
448
+ "description": "Truncate by words"
449
+ },
450
+ "filter-truncatechars": {
451
+ "prefix": "truncatechars",
452
+ "body": "{{ ${1:text}|truncatechars:${2:100} }}",
453
+ "description": "Truncate by characters"
454
+ },
455
+ "filter-striptags": {
456
+ "prefix": "striptags",
457
+ "body": "{{ ${1:html}|striptags }}",
458
+ "description": "Strip HTML tags"
459
+ },
460
+ "filter-safe": {
461
+ "prefix": "safe",
462
+ "body": "{{ ${1:html}|safe }}",
463
+ "description": "Mark as HTML safe"
464
+ },
465
+ "filter-escape": {
466
+ "prefix": "escape",
467
+ "body": "{{ ${1:value}|escape }}",
468
+ "description": "Escape HTML"
469
+ },
470
+ "filter-linebreaks": {
471
+ "prefix": "linebreaks",
472
+ "body": "{{ ${1:text}|linebreaks }}",
473
+ "description": "Convert line breaks to HTML"
474
+ },
475
+ "filter-date": {
476
+ "prefix": "date",
477
+ "body": "{{ ${1:date}|date:\"${2:Y-m-d}\" }}",
478
+ "description": "Format date"
479
+ },
480
+ "filter-time": {
481
+ "prefix": "time",
482
+ "body": "{{ ${1:date}|time:\"${2:H:i}\" }}",
483
+ "description": "Format time"
484
+ },
485
+ "filter-add": {
486
+ "prefix": "add",
487
+ "body": "{{ ${1:value}|add:${2:1} }}",
488
+ "description": "Add value"
166
489
  },
167
- "filter_block": {
168
- "prefix": "filter",
490
+ "filter-floatformat": {
491
+ "prefix": "floatformat",
492
+ "body": "{{ ${1:value}|floatformat:${2:2} }}",
493
+ "description": "Format decimal"
494
+ },
495
+ "filter-divisibleby": {
496
+ "prefix": "divisibleby",
497
+ "body": "{{ ${1:value}|divisibleby:${2:2} }}",
498
+ "description": "Check divisibility"
499
+ },
500
+ "filter-mod": {
501
+ "prefix": "mod",
502
+ "body": "{{ ${1:value}|mod:${2:2} }}",
503
+ "description": "Modulo operation"
504
+ },
505
+ "filter-with": {
506
+ "prefix": "with-filter",
507
+ "body": "{{ ${1:value}|with:${2:var}=${3:value} }}",
508
+ "description": "Add context to value"
509
+ },
510
+ "filter-json-script": {
511
+ "prefix": "json_script",
512
+ "body": "{{ ${1:data}|json_script:${2:'id'} }}",
513
+ "description": "JSON script tag"
514
+ },
515
+ "filter-urlencode": {
516
+ "prefix": "urlencode",
517
+ "body": "{{ ${1:value}|urlencode }}",
518
+ "description": "URL encode"
519
+ },
520
+ "filter-yesno": {
521
+ "prefix": "yesno",
522
+ "body": "{{ ${1:value}|yesno:\"${2:yes,no,maybe}\" }}",
523
+ "description": "Yes/No/Maybe mapping"
524
+ },
525
+ "filter-pluralize": {
526
+ "prefix": "pluralize",
527
+ "body": "{{ ${1:count}|pluralize }}",
528
+ "description": "Pluralize suffix"
529
+ },
530
+ "filter-pluralize-custom": {
531
+ "prefix": "pluralize-custom",
532
+ "body": "{{ ${1:count}|pluralize:\"${2:y,ies}\" }}",
533
+ "description": "Custom plural suffix"
534
+ },
535
+ "filter-filesizeformat": {
536
+ "prefix": "filesizeformat",
537
+ "body": "{{ ${1:bytes}|filesizeformat }}",
538
+ "description": "Format file size"
539
+ },
540
+ "filter-intcomma": {
541
+ "prefix": "intcomma",
542
+ "body": "{{ ${1:number}|intcomma }}",
543
+ "description": "Integer with commas"
544
+ },
545
+ "filter-timesince": {
546
+ "prefix": "timesince",
547
+ "body": "{{ ${1:date}|timesince }}",
548
+ "description": "Time since"
549
+ },
550
+ "filter-timeuntil": {
551
+ "prefix": "timeuntil",
552
+ "body": "{{ ${1:date}|timeuntil }}",
553
+ "description": "Time until"
554
+ },
555
+ "filter-strftime": {
556
+ "prefix": "strftime",
557
+ "body": "{{ ${1:date}|strftime:\"${2:PPpp}\" }}",
558
+ "description": "Format with date-fns"
559
+ },
560
+ "filter-dictsort": {
561
+ "prefix": "dictsort",
562
+ "body": "{{ ${1:list}|dictsort:\"${2:key}\" }}",
563
+ "description": "Sort by key"
564
+ },
565
+ "filter-dictsortreversed": {
566
+ "prefix": "dictsortreversed",
567
+ "body": "{{ ${1:list}|dictsortreversed:\"${2:key}\" }}",
568
+ "description": "Sort by key (reversed)"
569
+ },
570
+ "filter-slugify": {
571
+ "prefix": "slugify",
572
+ "body": "{{ ${1:value}|slugify }}",
573
+ "description": "URL-friendly slug"
574
+ },
575
+ "filter-wordcount": {
576
+ "prefix": "wordcount",
577
+ "body": "{{ ${1:text}|wordcount }}",
578
+ "description": "Count words"
579
+ },
580
+ "filter-phone2numeric": {
581
+ "prefix": "phone2numeric",
582
+ "body": "{{ ${1:value}|phone2numeric }}",
583
+ "description": "Phone to numeric"
584
+ },
585
+ "filter-center": {
586
+ "prefix": "center",
587
+ "body": "{{ ${1:value}|center:${2:10} }}",
588
+ "description": "Center text"
589
+ },
590
+ "filter-ljust": {
591
+ "prefix": "ljust",
592
+ "body": "{{ ${1:value}|ljust:${2:10} }}",
593
+ "description": "Left justify"
594
+ },
595
+ "filter-rjust": {
596
+ "prefix": "rjust",
597
+ "body": "{{ ${1:value}|rjust:${2:10} }}",
598
+ "description": "Right justify"
599
+ },
600
+ "filter-stringformat": {
601
+ "prefix": "stringformat",
602
+ "body": "{{ ${1:value}|stringformat:\"${2:s}\" }}",
603
+ "description": "String format"
604
+ },
605
+ "filter-cut": {
606
+ "prefix": "cut",
607
+ "body": "{{ ${1:value}|cut:\"${2: }\" }}",
608
+ "description": "Remove characters"
609
+ },
610
+ "filter-addslashes": {
611
+ "prefix": "addslashes",
612
+ "body": "{{ ${1:value}|addslashes }}",
613
+ "description": "Add slashes"
614
+ },
615
+ "filter-removetags": {
616
+ "prefix": "removetags",
617
+ "body": "{{ ${1:html}|removetags:\"${2:p,div}\" }}",
618
+ "description": "Remove specific tags"
619
+ },
620
+ "filter-split": {
621
+ "prefix": "split",
622
+ "body": "{{ ${1:value}|split:\"${2:,}\" }}",
623
+ "description": "Split string"
624
+ },
625
+ "filter-trans": {
626
+ "prefix": "trans-filter",
627
+ "body": "{{ ${1:value}|trans }}",
628
+ "description": "Translate value"
629
+ },
630
+ "filter-naturalday": {
631
+ "prefix": "naturalday",
632
+ "body": "{{ ${1:date}|naturalday }}",
633
+ "description": "Natural day format"
634
+ },
635
+ "filter-apnumber": {
636
+ "prefix": "apnumber",
637
+ "body": "{{ ${1:number}|apnumber }}",
638
+ "description": "American English number"
639
+ },
640
+ "filter-ordinal": {
641
+ "prefix": "ordinal",
642
+ "body": "{{ ${1:number}|ordinal }}",
643
+ "description": "Ordinal (1st, 2nd, etc.)"
644
+ },
645
+ "filter-intword": {
646
+ "prefix": "intword",
647
+ "body": "{{ ${1:number}|intword }}",
648
+ "description": "Large integer to word"
649
+ },
650
+ "filter-get-digit": {
651
+ "prefix": "get_digit",
652
+ "body": "{{ ${1:number}|get_digit:${2:1} }}",
653
+ "description": "Get digit by position"
654
+ },
655
+ "filter-regroup": {
656
+ "prefix": "regroup-filter",
657
+ "body": "{{ ${1:list}|regroup:\"${2:key}\" }}",
658
+ "description": "Regroup list"
659
+ },
660
+ "for-forloop": {
661
+ "prefix": "for-forloop",
169
662
  "body": [
170
- "{% filter ${1:lower} %}",
171
- " ${2}",
172
- "{% endfilter %}"
663
+ "{% for ${1:item} in ${2:items} %}",
664
+ " {% if forloop.first %}",
665
+ " <ul>",
666
+ " {% endif %}",
667
+ " <li>{{ forloop.counter }}: {{ ${1} }}</li>",
668
+ " {% if forloop.last %}",
669
+ " </ul>",
670
+ " {% endif %}",
671
+ "{% endfor %}"
173
672
  ],
174
- "description": "Filter block"
673
+ "description": "For loop with first/last detection"
674
+ },
675
+ "block-wrap": {
676
+ "prefix": "block-wrap",
677
+ "body": [
678
+ "{% block ${1:name} %}",
679
+ " $TM_SELECTED_TEXT",
680
+ "{% endblock %}"
681
+ ],
682
+ "description": "Wrap selection in block"
683
+ },
684
+ "for-wrap": {
685
+ "prefix": "for-wrap",
686
+ "body": [
687
+ "{% for ${1:item} in ${2:items} %}",
688
+ " $TM_SELECTED_TEXT",
689
+ "{% endfor %}"
690
+ ],
691
+ "description": "Wrap selection in for loop"
692
+ },
693
+ "if-wrap": {
694
+ "prefix": "if-wrap",
695
+ "body": [
696
+ "{% if ${1:condition} %}",
697
+ " $TM_SELECTED_TEXT",
698
+ "{% endif %}"
699
+ ],
700
+ "description": "Wrap selection in if"
701
+ },
702
+ "with-wrap": {
703
+ "prefix": "with-wrap",
704
+ "body": [
705
+ "{% with ${1:var} as ${2:alias} %}",
706
+ " $TM_SELECTED_TEXT",
707
+ "{% endwith %}"
708
+ ],
709
+ "description": "Wrap selection in with"
710
+ },
711
+ "filter-wrap": {
712
+ "prefix": "filter-wrap",
713
+ "body": "${TM_SELECTED_TEXT}|${1:filter}",
714
+ "description": "Wrap selection with filter"
175
715
  }
176
716
  }
177
717
  }