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
|
@@ -1,219 +1,219 @@
|
|
|
1
|
-
# Express
|
|
2
|
-
|
|
3
|
-
Express is the most common integration. Use `setupExpress()` for one-line setup.
|
|
4
|
-
|
|
5
|
-
## Setup
|
|
6
|
-
|
|
7
|
-
=== "CommonJS"
|
|
8
|
-
|
|
9
|
-
```javascript
|
|
10
|
-
const express = require('express');
|
|
11
|
-
const miki = require('miki-template');
|
|
12
|
-
|
|
13
|
-
const app = express();
|
|
14
|
-
miki.setupExpress(app, { extension: 'html', views: './views' });
|
|
15
|
-
|
|
16
|
-
app.get('/', (req, res) => res.render('home', { user: req.user }));
|
|
17
|
-
app.get('/partials/:name', (req, res) =>
|
|
18
|
-
res.render(`home#${req.params.name}`, { user: req.user })
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
app.listen(3000);
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
=== "ES Modules"
|
|
25
|
-
|
|
26
|
-
```javascript
|
|
27
|
-
import express from 'express';
|
|
28
|
-
import miki from 'miki-template';
|
|
29
|
-
|
|
30
|
-
const app = express();
|
|
31
|
-
miki.setupExpress(app, { extension: 'html', views: './views' });
|
|
32
|
-
|
|
33
|
-
app.get('/', (req, res) => res.render('home', { user: req.user }));
|
|
34
|
-
app.get('/partials/:name', (req, res) =>
|
|
35
|
-
res.render(`home#${req.params.name}`, { user: req.user })
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
app.listen(3000);
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## Options
|
|
42
|
-
|
|
43
|
-
| Option | Default | Description |
|
|
44
|
-
|--------|---------|-------------|
|
|
45
|
-
| `extension` | `'html'` | File extension for views. Use `'miki'` if you prefer `.miki` files. |
|
|
46
|
-
| `views` | `app.get('views')` | Views directory (passed to `app.set('views', ...)`). |
|
|
47
|
-
| `async` | `false` | Use the async engine (`__expressAsync`). For Express 5+ with async helpers. |
|
|
48
|
-
|
|
49
|
-
> The `res.render` shim intercepts **only** view names containing a `#`. Everything else (full pages, `res.render(view, cb)`, callback forms) goes through Express's normal view lookup, so the integration is fully compatible with existing Express middleware.
|
|
50
|
-
|
|
51
|
-
## Manual Setup
|
|
52
|
-
|
|
53
|
-
If you prefer full control:
|
|
54
|
-
|
|
55
|
-
=== "CommonJS"
|
|
56
|
-
|
|
57
|
-
```javascript
|
|
58
|
-
const express = require('express');
|
|
59
|
-
const { __express } = require('miki-template');
|
|
60
|
-
|
|
61
|
-
const app = express();
|
|
62
|
-
app.engine('html', __express);
|
|
63
|
-
app.set('view engine', 'html');
|
|
64
|
-
app.set('views', './views');
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
=== "ES Modules"
|
|
68
|
-
|
|
69
|
-
```javascript
|
|
70
|
-
import express from 'express';
|
|
71
|
-
import { __express } from 'miki-template';
|
|
72
|
-
|
|
73
|
-
const app = express();
|
|
74
|
-
app.engine('html', __express);
|
|
75
|
-
app.set('view engine', 'html');
|
|
76
|
-
app.set('views', './views');
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Async Express 5+
|
|
80
|
-
|
|
81
|
-
Express 5+ supports async route handlers natively. Pass `async: true` to `setupExpress`, or use `__expressAsync` directly:
|
|
82
|
-
|
|
83
|
-
=== "CommonJS"
|
|
84
|
-
|
|
85
|
-
```javascript
|
|
86
|
-
const express = require('express');
|
|
87
|
-
const miki = require('miki-template');
|
|
88
|
-
|
|
89
|
-
const app = express();
|
|
90
|
-
miki.setupExpress(app, { extension: 'html', views: './views', async: true });
|
|
91
|
-
|
|
92
|
-
app.get('/user/:id', async (req, res) => {
|
|
93
|
-
const user = await User.findById(req.params.id);
|
|
94
|
-
if (!user) return res.status(404).send('Not found');
|
|
95
|
-
res.render('user-profile', { user });
|
|
96
|
-
});
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
=== "ES Modules"
|
|
100
|
-
|
|
101
|
-
```javascript
|
|
102
|
-
import express from 'express';
|
|
103
|
-
import miki from 'miki-template';
|
|
104
|
-
|
|
105
|
-
const app = express();
|
|
106
|
-
miki.setupExpress(app, { extension: 'html', views: './views', async: true });
|
|
107
|
-
|
|
108
|
-
app.get('/user/:id', async (req, res) => {
|
|
109
|
-
const user = await User.findById(req.params.id);
|
|
110
|
-
if (!user) return res.status(404).send('Not found');
|
|
111
|
-
res.render('user-profile', { user });
|
|
112
|
-
});
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
## Partial Renderer Middleware
|
|
116
|
-
|
|
117
|
-
Add partial rendering without changing engine registration:
|
|
118
|
-
|
|
119
|
-
=== "CommonJS"
|
|
120
|
-
|
|
121
|
-
```javascript
|
|
122
|
-
const express = require('express');
|
|
123
|
-
const miki = require('miki-template');
|
|
124
|
-
|
|
125
|
-
const app = express();
|
|
126
|
-
miki.setupExpress(app, { extension: 'html', views: './views' });
|
|
127
|
-
app.use(miki.expressPartialRenderer());
|
|
128
|
-
|
|
129
|
-
app.get('/card', (req, res) => res.renderPartial('home#card', { user: req.user }));
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
=== "ES Modules"
|
|
133
|
-
|
|
134
|
-
```javascript
|
|
135
|
-
import express from 'express';
|
|
136
|
-
import miki from 'miki-template';
|
|
137
|
-
|
|
138
|
-
const app = express();
|
|
139
|
-
miki.setupExpress(app, { extension: 'html', views: './views' });
|
|
140
|
-
// Note: must call expressPartialRenderer() before routes
|
|
141
|
-
app.use(miki.expressPartialRenderer());
|
|
142
|
-
|
|
143
|
-
app.get('/card', (req, res) => res.renderPartial('home#card', { user: req.user }));
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
## Express Adapter (app.engine)
|
|
147
|
-
|
|
148
|
-
If you prefer not to use `setupExpress()`, you can use `express()` directly as a view engine:
|
|
149
|
-
|
|
150
|
-
=== "CommonJS"
|
|
151
|
-
|
|
152
|
-
```javascript
|
|
153
|
-
const express = require('express');
|
|
154
|
-
const { express: mikiExpress } = require('miki-template');
|
|
155
|
-
|
|
156
|
-
const app = express();
|
|
157
|
-
app.engine('html', mikiExpress({ async: true }));
|
|
158
|
-
app.set('view engine', 'html');
|
|
159
|
-
app.set('views', './views');
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
=== "ES Modules"
|
|
163
|
-
|
|
164
|
-
```javascript
|
|
165
|
-
import express from 'express';
|
|
166
|
-
import { express as mikiExpress } from 'miki-template';
|
|
167
|
-
|
|
168
|
-
const app = express();
|
|
169
|
-
app.engine('html', mikiExpress({ async: true }));
|
|
170
|
-
app.set('view engine', 'html');
|
|
171
|
-
app.set('views', './views');
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
## HTMX Example
|
|
175
|
-
|
|
176
|
-
miki-template's partial rendering (`#partialName`) is purpose-built for HTMX and similar frameworks:
|
|
177
|
-
|
|
178
|
-
=== "CommonJS"
|
|
179
|
-
|
|
180
|
-
```javascript
|
|
181
|
-
const express = require('express');
|
|
182
|
-
const miki = require('miki-template');
|
|
183
|
-
|
|
184
|
-
const app = express();
|
|
185
|
-
miki.setupExpress(app, { extension: 'html', views: './views' });
|
|
186
|
-
|
|
187
|
-
// Full page — initial load
|
|
188
|
-
app.get('/', (req, res) => res.render('home', { user: req.user }));
|
|
189
|
-
|
|
190
|
-
// HTMX partial — only re-renders the "card" component
|
|
191
|
-
app.get('/partials/:name', (req, res) =>
|
|
192
|
-
res.render(`home#${req.params.name}`, { user: req.user })
|
|
193
|
-
);
|
|
194
|
-
|
|
195
|
-
app.listen(3000);
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
=== "ES Modules"
|
|
199
|
-
|
|
200
|
-
```javascript
|
|
201
|
-
import express from 'express';
|
|
202
|
-
import miki from 'miki-template';
|
|
203
|
-
|
|
204
|
-
const app = express();
|
|
205
|
-
miki.setupExpress(app, { extension: 'html', views: './views' });
|
|
206
|
-
|
|
207
|
-
app.get('/', (req, res) => res.render('home', { user: req.user }));
|
|
208
|
-
|
|
209
|
-
app.get('/partials/:name', (req, res) =>
|
|
210
|
-
res.render(`home#${req.params.name}`, { user: req.user })
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
app.listen(3000);
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
## Next Steps
|
|
217
|
-
|
|
218
|
-
- [Integrations Overview](../)
|
|
219
|
-
- [API Reference: setupExpress](../api/setup-express)
|
|
1
|
+
# Express
|
|
2
|
+
|
|
3
|
+
Express is the most common integration. Use `setupExpress()` for one-line setup.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
=== "CommonJS"
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
const express = require('express');
|
|
11
|
+
const miki = require('miki-template');
|
|
12
|
+
|
|
13
|
+
const app = express();
|
|
14
|
+
miki.setupExpress(app, { extension: 'html', views: './views' });
|
|
15
|
+
|
|
16
|
+
app.get('/', (req, res) => res.render('home', { user: req.user }));
|
|
17
|
+
app.get('/partials/:name', (req, res) =>
|
|
18
|
+
res.render(`home#${req.params.name}`, { user: req.user })
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
app.listen(3000);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
=== "ES Modules"
|
|
25
|
+
|
|
26
|
+
```javascript
|
|
27
|
+
import express from 'express';
|
|
28
|
+
import miki from 'miki-template';
|
|
29
|
+
|
|
30
|
+
const app = express();
|
|
31
|
+
miki.setupExpress(app, { extension: 'html', views: './views' });
|
|
32
|
+
|
|
33
|
+
app.get('/', (req, res) => res.render('home', { user: req.user }));
|
|
34
|
+
app.get('/partials/:name', (req, res) =>
|
|
35
|
+
res.render(`home#${req.params.name}`, { user: req.user })
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
app.listen(3000);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Options
|
|
42
|
+
|
|
43
|
+
| Option | Default | Description |
|
|
44
|
+
|--------|---------|-------------|
|
|
45
|
+
| `extension` | `'html'` | File extension for views. Use `'miki'` if you prefer `.miki` files. |
|
|
46
|
+
| `views` | `app.get('views')` | Views directory (passed to `app.set('views', ...)`). |
|
|
47
|
+
| `async` | `false` | Use the async engine (`__expressAsync`). For Express 5+ with async helpers. |
|
|
48
|
+
|
|
49
|
+
> The `res.render` shim intercepts **only** view names containing a `#`. Everything else (full pages, `res.render(view, cb)`, callback forms) goes through Express's normal view lookup, so the integration is fully compatible with existing Express middleware.
|
|
50
|
+
|
|
51
|
+
## Manual Setup
|
|
52
|
+
|
|
53
|
+
If you prefer full control:
|
|
54
|
+
|
|
55
|
+
=== "CommonJS"
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
const express = require('express');
|
|
59
|
+
const { __express } = require('miki-template');
|
|
60
|
+
|
|
61
|
+
const app = express();
|
|
62
|
+
app.engine('html', __express);
|
|
63
|
+
app.set('view engine', 'html');
|
|
64
|
+
app.set('views', './views');
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
=== "ES Modules"
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
import express from 'express';
|
|
71
|
+
import { __express } from 'miki-template';
|
|
72
|
+
|
|
73
|
+
const app = express();
|
|
74
|
+
app.engine('html', __express);
|
|
75
|
+
app.set('view engine', 'html');
|
|
76
|
+
app.set('views', './views');
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Async Express 5+
|
|
80
|
+
|
|
81
|
+
Express 5+ supports async route handlers natively. Pass `async: true` to `setupExpress`, or use `__expressAsync` directly:
|
|
82
|
+
|
|
83
|
+
=== "CommonJS"
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
const express = require('express');
|
|
87
|
+
const miki = require('miki-template');
|
|
88
|
+
|
|
89
|
+
const app = express();
|
|
90
|
+
miki.setupExpress(app, { extension: 'html', views: './views', async: true });
|
|
91
|
+
|
|
92
|
+
app.get('/user/:id', async (req, res) => {
|
|
93
|
+
const user = await User.findById(req.params.id);
|
|
94
|
+
if (!user) return res.status(404).send('Not found');
|
|
95
|
+
res.render('user-profile', { user });
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
=== "ES Modules"
|
|
100
|
+
|
|
101
|
+
```javascript
|
|
102
|
+
import express from 'express';
|
|
103
|
+
import miki from 'miki-template';
|
|
104
|
+
|
|
105
|
+
const app = express();
|
|
106
|
+
miki.setupExpress(app, { extension: 'html', views: './views', async: true });
|
|
107
|
+
|
|
108
|
+
app.get('/user/:id', async (req, res) => {
|
|
109
|
+
const user = await User.findById(req.params.id);
|
|
110
|
+
if (!user) return res.status(404).send('Not found');
|
|
111
|
+
res.render('user-profile', { user });
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Partial Renderer Middleware
|
|
116
|
+
|
|
117
|
+
Add partial rendering without changing engine registration:
|
|
118
|
+
|
|
119
|
+
=== "CommonJS"
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
const express = require('express');
|
|
123
|
+
const miki = require('miki-template');
|
|
124
|
+
|
|
125
|
+
const app = express();
|
|
126
|
+
miki.setupExpress(app, { extension: 'html', views: './views' });
|
|
127
|
+
app.use(miki.expressPartialRenderer());
|
|
128
|
+
|
|
129
|
+
app.get('/card', (req, res) => res.renderPartial('home#card', { user: req.user }));
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
=== "ES Modules"
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
import express from 'express';
|
|
136
|
+
import miki from 'miki-template';
|
|
137
|
+
|
|
138
|
+
const app = express();
|
|
139
|
+
miki.setupExpress(app, { extension: 'html', views: './views' });
|
|
140
|
+
// Note: must call expressPartialRenderer() before routes
|
|
141
|
+
app.use(miki.expressPartialRenderer());
|
|
142
|
+
|
|
143
|
+
app.get('/card', (req, res) => res.renderPartial('home#card', { user: req.user }));
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Express Adapter (app.engine)
|
|
147
|
+
|
|
148
|
+
If you prefer not to use `setupExpress()`, you can use `express()` directly as a view engine:
|
|
149
|
+
|
|
150
|
+
=== "CommonJS"
|
|
151
|
+
|
|
152
|
+
```javascript
|
|
153
|
+
const express = require('express');
|
|
154
|
+
const { express: mikiExpress } = require('miki-template');
|
|
155
|
+
|
|
156
|
+
const app = express();
|
|
157
|
+
app.engine('html', mikiExpress({ async: true }));
|
|
158
|
+
app.set('view engine', 'html');
|
|
159
|
+
app.set('views', './views');
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
=== "ES Modules"
|
|
163
|
+
|
|
164
|
+
```javascript
|
|
165
|
+
import express from 'express';
|
|
166
|
+
import { express as mikiExpress } from 'miki-template';
|
|
167
|
+
|
|
168
|
+
const app = express();
|
|
169
|
+
app.engine('html', mikiExpress({ async: true }));
|
|
170
|
+
app.set('view engine', 'html');
|
|
171
|
+
app.set('views', './views');
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## HTMX Example
|
|
175
|
+
|
|
176
|
+
miki-template's partial rendering (`#partialName`) is purpose-built for HTMX and similar frameworks:
|
|
177
|
+
|
|
178
|
+
=== "CommonJS"
|
|
179
|
+
|
|
180
|
+
```javascript
|
|
181
|
+
const express = require('express');
|
|
182
|
+
const miki = require('miki-template');
|
|
183
|
+
|
|
184
|
+
const app = express();
|
|
185
|
+
miki.setupExpress(app, { extension: 'html', views: './views' });
|
|
186
|
+
|
|
187
|
+
// Full page — initial load
|
|
188
|
+
app.get('/', (req, res) => res.render('home', { user: req.user }));
|
|
189
|
+
|
|
190
|
+
// HTMX partial — only re-renders the "card" component
|
|
191
|
+
app.get('/partials/:name', (req, res) =>
|
|
192
|
+
res.render(`home#${req.params.name}`, { user: req.user })
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
app.listen(3000);
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
=== "ES Modules"
|
|
199
|
+
|
|
200
|
+
```javascript
|
|
201
|
+
import express from 'express';
|
|
202
|
+
import miki from 'miki-template';
|
|
203
|
+
|
|
204
|
+
const app = express();
|
|
205
|
+
miki.setupExpress(app, { extension: 'html', views: './views' });
|
|
206
|
+
|
|
207
|
+
app.get('/', (req, res) => res.render('home', { user: req.user }));
|
|
208
|
+
|
|
209
|
+
app.get('/partials/:name', (req, res) =>
|
|
210
|
+
res.render(`home#${req.params.name}`, { user: req.user })
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
app.listen(3000);
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Next Steps
|
|
217
|
+
|
|
218
|
+
- [Integrations Overview](../index.md)
|
|
219
|
+
- [API Reference: setupExpress](../api/setup-express.md)
|
|
@@ -73,5 +73,7 @@ Use miki-template with Fastify by calling `asyncRender()` inline in your route h
|
|
|
73
73
|
|
|
74
74
|
## Next Steps
|
|
75
75
|
|
|
76
|
-
- [Integrations Overview](../)
|
|
77
|
-
- [API Reference: asyncRender
|
|
76
|
+
- [Integrations Overview](../index.md)
|
|
77
|
+
- [API Reference: asyncRender param($m) $m.Value -replace '([a-z][a-z0-9-]+)\.md
|
|
78
|
+
, '../.md' -replace '([a-z][a-z0-9-]+)
|
|
79
|
+
, '../.md'
|
|
@@ -74,5 +74,7 @@ Use miki-template with Hono (ESM-first framework) by calling `asyncRender()` in
|
|
|
74
74
|
|
|
75
75
|
## Next Steps
|
|
76
76
|
|
|
77
|
-
- [Integrations Overview](../)
|
|
78
|
-
- [API Reference: asyncRender
|
|
77
|
+
- [Integrations Overview](../index.md)
|
|
78
|
+
- [API Reference: asyncRender param($m) $m.Value -replace '([a-z][a-z0-9-]+)\.md
|
|
79
|
+
, '../.md' -replace '([a-z][a-z0-9-]+)
|
|
80
|
+
, '../.md'
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
# Integrations Overview
|
|
2
|
-
|
|
3
|
-
miki-template works with all major Node.js web frameworks. Use `render()` for synchronous output or `asyncRender()` for templates with async filters/tags.
|
|
4
|
-
|
|
5
|
-
## Supported Frameworks
|
|
6
|
-
|
|
7
|
-
- [Express](./express) — One-line setup with `setupExpress()`
|
|
8
|
-
- [Koa](./koa) — Context helper using `asyncRender()`
|
|
9
|
-
- [Fastify](./fastify) — Inline `asyncRender()` calls
|
|
10
|
-
- [Hono](./hono) — ESM-first, using `asyncRender()`
|
|
11
|
-
- [Elysia](./elysia) — ESM-first, using `asyncRender()`
|
|
12
|
-
- [NestJS](./nestjs) — Module/Provider pattern
|
|
13
|
-
- [TSDX / TS-Economy (TSed)](./tsed) — TypeScript integration
|
|
14
|
-
|
|
15
|
-
## Quick Example
|
|
16
|
-
|
|
17
|
-
=== "CommonJS"
|
|
18
|
-
|
|
19
|
-
```javascript
|
|
20
|
-
const express = require('express');
|
|
21
|
-
const miki = require('miki-template');
|
|
22
|
-
|
|
23
|
-
const app = express();
|
|
24
|
-
miki.setupExpress(app, { extension: 'html', views: './views' });
|
|
25
|
-
|
|
26
|
-
app.get('/', (req, res) => res.render('home', { user: req.user }));
|
|
27
|
-
|
|
28
|
-
app.listen(3000);
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
=== "ES Modules"
|
|
32
|
-
|
|
33
|
-
```javascript
|
|
34
|
-
import express from 'express';
|
|
35
|
-
import miki from 'miki-template';
|
|
36
|
-
|
|
37
|
-
const app = express();
|
|
38
|
-
miki.setupExpress(app, { extension: 'html', views: './views' });
|
|
39
|
-
|
|
40
|
-
app.get('/', (req, res) => res.render('home', { user: req.user }));
|
|
41
|
-
|
|
42
|
-
app.listen(3000);
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Notes
|
|
46
|
-
|
|
47
|
-
- For CommonJS: `const miki = require('miki-template');`
|
|
48
|
-
- For ESM / Bun: `import miki from 'miki-template';` or `import * as miki from 'miki-template';`
|
|
49
|
-
- When rendering files, pass `options.views` or set framework view roots so the engine can locate templates.
|
|
50
|
-
- Use `asyncRender()` if your templates use async filters, async tags, or `{% load %}` libraries with async components.
|
|
51
|
-
|
|
52
|
-
## Installation
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
# npm
|
|
56
|
-
npm install miki-template
|
|
57
|
-
|
|
58
|
-
# bun
|
|
59
|
-
bun add miki-template
|
|
60
|
-
|
|
61
|
-
# yarn
|
|
62
|
-
yarn add miki-template
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Next Steps
|
|
66
|
-
|
|
67
|
-
- [Express Integration](./express)
|
|
68
|
-
- [API Reference: render](../api/render)
|
|
1
|
+
# Integrations Overview
|
|
2
|
+
|
|
3
|
+
miki-template works with all major Node.js web frameworks. Use `render()` for synchronous output or `asyncRender()` for templates with async filters/tags.
|
|
4
|
+
|
|
5
|
+
## Supported Frameworks
|
|
6
|
+
|
|
7
|
+
- [Express](./express.md) — One-line setup with `setupExpress()`
|
|
8
|
+
- [Koa](./koa.md) — Context helper using `asyncRender()`
|
|
9
|
+
- [Fastify](./fastify.md) — Inline `asyncRender()` calls
|
|
10
|
+
- [Hono](./hono.md) — ESM-first, using `asyncRender()`
|
|
11
|
+
- [Elysia](./elysia.md) — ESM-first, using `asyncRender()`
|
|
12
|
+
- [NestJS](./nestjs.md) — Module/Provider pattern
|
|
13
|
+
- [TSDX / TS-Economy (TSed)](./tsed.md) — TypeScript integration
|
|
14
|
+
|
|
15
|
+
## Quick Example
|
|
16
|
+
|
|
17
|
+
=== "CommonJS"
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
const express = require('express');
|
|
21
|
+
const miki = require('miki-template');
|
|
22
|
+
|
|
23
|
+
const app = express();
|
|
24
|
+
miki.setupExpress(app, { extension: 'html', views: './views' });
|
|
25
|
+
|
|
26
|
+
app.get('/', (req, res) => res.render('home', { user: req.user }));
|
|
27
|
+
|
|
28
|
+
app.listen(3000);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
=== "ES Modules"
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
import express from 'express';
|
|
35
|
+
import miki from 'miki-template';
|
|
36
|
+
|
|
37
|
+
const app = express();
|
|
38
|
+
miki.setupExpress(app, { extension: 'html', views: './views' });
|
|
39
|
+
|
|
40
|
+
app.get('/', (req, res) => res.render('home', { user: req.user }));
|
|
41
|
+
|
|
42
|
+
app.listen(3000);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Notes
|
|
46
|
+
|
|
47
|
+
- For CommonJS: `const miki = require('miki-template');`
|
|
48
|
+
- For ESM / Bun: `import miki from 'miki-template';` or `import * as miki from 'miki-template';`
|
|
49
|
+
- When rendering files, pass `options.views` or set framework view roots so the engine can locate templates.
|
|
50
|
+
- Use `asyncRender()` if your templates use async filters, async tags, or `{% load %}` libraries with async components.
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# npm
|
|
56
|
+
npm install miki-template
|
|
57
|
+
|
|
58
|
+
# bun
|
|
59
|
+
bun add miki-template
|
|
60
|
+
|
|
61
|
+
# yarn
|
|
62
|
+
yarn add miki-template
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Next Steps
|
|
66
|
+
|
|
67
|
+
- [Express Integration](./express.md)
|
|
68
|
+
- [API Reference: render](../api/render.md)
|
package/docs/integrations/koa.md
CHANGED
|
@@ -84,5 +84,7 @@ Use miki-template with Koa by attaching an async render helper to the context.
|
|
|
84
84
|
|
|
85
85
|
## Next Steps
|
|
86
86
|
|
|
87
|
-
- [Integrations Overview](../)
|
|
88
|
-
- [API Reference: asyncRender
|
|
87
|
+
- [Integrations Overview](../index.md)
|
|
88
|
+
- [API Reference: asyncRender param($m) $m.Value -replace '([a-z][a-z0-9-]+)\.md
|
|
89
|
+
, '../.md' -replace '([a-z][a-z0-9-]+)
|
|
90
|
+
, '../.md'
|
|
@@ -74,5 +74,7 @@ renderCard(@Req() req: Request, @Res() res: Response) {
|
|
|
74
74
|
|
|
75
75
|
## Next Steps
|
|
76
76
|
|
|
77
|
-
- [Integrations Overview](../)
|
|
78
|
-
- [API Reference: setupExpress
|
|
77
|
+
- [Integrations Overview](../index.md)
|
|
78
|
+
- [API Reference: setupExpress param($m) $m.Value -replace '([a-z][a-z0-9-]+)\.md
|
|
79
|
+
, '../.md' -replace '([a-z][a-z0-9-]+)
|
|
80
|
+
, '../.md'
|
|
@@ -77,5 +77,7 @@ renderCard(@Req() req: Request, @Res() res: Response) {
|
|
|
77
77
|
|
|
78
78
|
## Next Steps
|
|
79
79
|
|
|
80
|
-
- [Integrations Overview](../)
|
|
81
|
-
- [API Reference: setupExpress
|
|
80
|
+
- [Integrations Overview](../index.md)
|
|
81
|
+
- [API Reference: setupExpress param($m) $m.Value -replace '([a-z][a-z0-9-]+)\.md
|
|
82
|
+
, '../.md' -replace '([a-z][a-z0-9-]+)
|
|
83
|
+
, '../.md'
|