miki-template 2.2.3 → 2.3.1
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/workflows/docs.yml +3 -1
- package/.github/workflows/release.yml +0 -5
- package/README.md +17 -5
- package/benchmarks/ejs-results.json +6 -6
- package/benchmarks/ejs.js +5 -3
- package/benchmarks/handlebars-results.json +6 -6
- package/benchmarks/handlebars.js +5 -8
- package/benchmarks/miki-results.json +6 -6
- package/benchmarks/miki.js +6 -3
- package/benchmarks/pug-results.json +6 -6
- package/benchmarks/pug.js +5 -3
- package/docs/api/async-render.md +88 -3
- package/docs/api/cache.md +90 -3
- package/docs/api/compile.md +131 -3
- package/docs/api/context-processors.md +80 -3
- package/docs/api/filters.md +223 -3
- package/docs/api/finder.md +97 -3
- package/docs/api/helpers.md +56 -3
- package/docs/api/i18n.md +160 -3
- package/docs/api/index.md +82 -28
- package/docs/api/libraries.md +210 -3
- package/docs/api/render-partial.md +84 -3
- package/docs/api/render.md +95 -3
- package/docs/api/security.md +148 -3
- package/docs/api/setup-express.md +78 -2
- package/docs/api/tags.md +138 -4
- package/docs/filter.md +0 -0
- package/docs/guide/advanced-usage.md +403 -6
- package/docs/guide/async-rendering.md +312 -4
- package/docs/guide/context-processors.md +261 -4
- package/docs/guide/custom-filters.md +315 -4
- package/docs/guide/custom-tags.md +275 -4
- package/docs/guide/filters.md +675 -3
- package/docs/guide/getting-started.md +109 -7
- package/docs/guide/installation.md +99 -4
- package/docs/guide/partial-templates.md +371 -4
- package/docs/guide/quick-start.md +228 -6
- package/docs/guide/security.md +348 -3
- package/docs/guide/tags.md +789 -6
- package/docs/guide/template-discovery.md +174 -4
- package/docs/guide/template-inheritance.md +277 -4
- package/docs/index.md +24 -42
- package/docs/integrations/elysia.md +4 -2
- package/docs/integrations/express.md +219 -219
- package/docs/integrations/fastify.md +4 -2
- package/docs/integrations/hono.md +4 -2
- package/docs/integrations/index.md +68 -68
- package/docs/integrations/koa.md +4 -2
- package/docs/integrations/nestjs.md +4 -2
- package/docs/integrations/tsed.md +4 -2
- package/docs/performance.md +45 -8
- package/ex.mjs +1 -1
- package/mkdocs.yml +0 -22
- package/overrides/main.html +1 -1
- package/package.json +1 -1
- package/requirements-docs.txt +2 -1
- package/src/codegen.js +905 -0
- package/src/context.js +42 -30
- package/src/filters.js +16 -0
- package/src/index.js +66 -61
- package/src/tags/control.js +15 -12
- package/src/utils.js +60 -0
- package/tests/filters.test.js +9 -0
- package/docs/javascripts/extra.js +0 -174
- package/docs/stylesheets/extra.css +0 -819
- package/overrides/partials/footer.html +0 -9
package/docs/performance.md
CHANGED
|
@@ -1,37 +1,74 @@
|
|
|
1
|
-
# Performance
|
|
1
|
+
# Performance
|
|
2
|
+
|
|
3
|
+
|
|
2
4
|
|
|
3
5
|
miki-template is built for real-world apps. Its compiled-AST engine is especially fast on templates with loops, conditionals, and filters — where other engines struggle.
|
|
4
6
|
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## Benchmark Results
|
|
6
10
|
|
|
11
|
+
|
|
12
|
+
|
|
7
13
|
Renders per second (higher is better):
|
|
8
14
|
|
|
15
|
+
|
|
16
|
+
|
|
9
17
|
| Template | miki-template | pug | handlebars | ejs |
|
|
18
|
+
|
|
10
19
|
|----------|--------------|-----|------------|-----|
|
|
11
|
-
|
|
12
|
-
|
|
|
13
|
-
|
|
20
|
+
|
|
21
|
+
| Small | ~1.1M rps | 1.1M rps | 300k rps | 113k rps |
|
|
22
|
+
|
|
23
|
+
| Medium | ~40k rps | 27k rps | 4k rps | 2k rps |
|
|
24
|
+
|
|
25
|
+
| Large | **~2530 rps** | 1886 rps | 493 rps | 1881 rps |
|
|
26
|
+
|
|
27
|
+
|
|
14
28
|
|
|
15
29
|
## Key Takeaways
|
|
16
30
|
|
|
17
|
-
|
|
18
|
-
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
- On **small** templates, miki-template is competitive with pug.
|
|
34
|
+
|
|
35
|
+
- On **medium** templates, miki-template beats pug.
|
|
36
|
+
|
|
19
37
|
- On **large/realistic** templates (the ones that matter in production), miki-template **dominates by ~150×**.
|
|
20
38
|
|
|
39
|
+
|
|
40
|
+
|
|
21
41
|
## Why miki-template Wins on Real Templates
|
|
22
42
|
|
|
43
|
+
|
|
44
|
+
|
|
23
45
|
- **Compiled AST**: Templates are compiled once and reused, avoiding repeated parsing.
|
|
46
|
+
|
|
24
47
|
- **No runtime interpretation**: No string concatenation or function reconstruction per render.
|
|
48
|
+
|
|
25
49
|
- **Optimized loops and filters**: for-loops and filters are implemented as efficient node traversals.
|
|
50
|
+
|
|
26
51
|
- **Cache-friendly**: Compiled templates are cached by default.
|
|
27
52
|
|
|
53
|
+
|
|
54
|
+
|
|
28
55
|
## Running Benchmarks
|
|
29
56
|
|
|
57
|
+
|
|
58
|
+
|
|
30
59
|
```bash
|
|
60
|
+
|
|
31
61
|
npm run bench
|
|
62
|
+
|
|
32
63
|
```
|
|
33
64
|
|
|
65
|
+
|
|
66
|
+
|
|
34
67
|
## Next Steps
|
|
35
68
|
|
|
36
|
-
|
|
37
|
-
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
- [Getting Started](guide/getting-started.md)
|
|
72
|
+
|
|
73
|
+
- [API Reference](api/index.md)
|
|
74
|
+
|
package/ex.mjs
CHANGED
|
@@ -26,7 +26,7 @@ const dir=path.join(process.cwd(),"dir")
|
|
|
26
26
|
{name:"miki", email:"jack@miki.com",address:"kumba"},
|
|
27
27
|
{name:"luis",email:"luis@miki.com",address:"kumba"}
|
|
28
28
|
]
|
|
29
|
-
res.render("index
|
|
29
|
+
res.render("index",{name:"miki-template context", users:users, data:data})
|
|
30
30
|
// res.send(content)
|
|
31
31
|
})
|
|
32
32
|
|
package/mkdocs.yml
CHANGED
|
@@ -150,18 +150,6 @@ markdown_extensions:
|
|
|
150
150
|
- pymdownx.tasklist:
|
|
151
151
|
custom_checkbox: true
|
|
152
152
|
- pymdownx.tilde
|
|
153
|
-
- material.extensions.emoji:
|
|
154
|
-
options:
|
|
155
|
-
custom_icons:
|
|
156
|
-
- overrides/.icons
|
|
157
|
-
- material.extensions.tabbed
|
|
158
|
-
- material.extensions.anchor
|
|
159
|
-
- material.extensions.details
|
|
160
|
-
- material.extensions.superfences
|
|
161
|
-
- material.extensions.magic-link:
|
|
162
|
-
repo_url_shorthand: true
|
|
163
|
-
user: alainmiki
|
|
164
|
-
repo: miki-template
|
|
165
153
|
|
|
166
154
|
extra:
|
|
167
155
|
social:
|
|
@@ -205,13 +193,3 @@ plugins:
|
|
|
205
193
|
- optimize:
|
|
206
194
|
enabled: !ENV [READTHEDOCS, false]
|
|
207
195
|
concurrency: 4
|
|
208
|
-
css:
|
|
209
|
-
transpile: true
|
|
210
|
-
js:
|
|
211
|
-
bundle: true
|
|
212
|
-
|
|
213
|
-
extra_css:
|
|
214
|
-
- stylesheets/extra.css
|
|
215
|
-
|
|
216
|
-
extra_javascript:
|
|
217
|
-
- javascripts/extra.js
|
package/overrides/main.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
{% block announce %}
|
|
4
4
|
<div class="md-announce" role="banner">
|
|
5
5
|
<div class="md-announce__inner">
|
|
6
|
-
<span>🚀 <strong>miki-template v2.
|
|
6
|
+
<span>🚀 <strong>miki-template v2.3.1</strong> is now available with improved performance and new features!</span>
|
|
7
7
|
<a href="https://github.com/alainmiki/miki-template/releases" target="_blank" rel="noopener">View Release Notes</a>
|
|
8
8
|
<button class="md-announce__button" onclick="this.closest('.md-announce').remove()" aria-label="Dismiss announcement">
|
|
9
9
|
<span class="md-icon">✕</span>
|
package/package.json
CHANGED
package/requirements-docs.txt
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
mkdocs-material[imaging]
|
|
1
|
+
mkdocs-material[imaging]<9.8
|
|
2
|
+
mkdocs<2
|