spooder 5.1.3 → 5.1.5
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/README.md +8 -0
- package/bun.lock +1 -1
- package/package.json +4 -2
- package/src/api.ts +4 -1
package/README.md
CHANGED
|
@@ -1317,6 +1317,7 @@ const server = http_serve(80);
|
|
|
1317
1317
|
|
|
1318
1318
|
server.bootstrap({
|
|
1319
1319
|
base: Bun.file('./html/base_template.html'),
|
|
1320
|
+
drop_missing_subs: false,
|
|
1320
1321
|
|
|
1321
1322
|
cache: {
|
|
1322
1323
|
ttl: 5 * 60 * 60 * 1000, // 5 minutes
|
|
@@ -1401,6 +1402,13 @@ server.bootstrap({
|
|
|
1401
1402
|
});
|
|
1402
1403
|
```
|
|
1403
1404
|
|
|
1405
|
+
##### `drop_missing_subs: boolean`
|
|
1406
|
+
|
|
1407
|
+
**Optional**. Defaults to true. If explicitly disabled, templating parsing will not drop unknown substitutions.
|
|
1408
|
+
|
|
1409
|
+
> ![NOTE]
|
|
1410
|
+
> If you are using a client-side framework that uses the double-brace syntax ``{{foo}}`` such as Vue, you should set this to `false` to ensure compatibility.
|
|
1411
|
+
|
|
1404
1412
|
##### `routes: Record<string, BootstrapRoute>`
|
|
1405
1413
|
**Required.** Defines the routes and their content. Each route can have:
|
|
1406
1414
|
- `content`: The page content (string or BunFile)
|
package/bun.lock
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"packages": {
|
|
15
15
|
"@types/bun": ["@types/bun@1.2.19", "", { "dependencies": { "bun-types": "1.2.19" } }, "sha512-d9ZCmrH3CJ2uYKXQIUuZ/pUnTqIvLDS0SK7pFmbx8ma+ziH/FRMoAq5bYpRG7y+w1gl+HgyNZbtqgMq4W4e2Lg=="],
|
|
16
16
|
|
|
17
|
-
"@types/node": ["@types/node@24.0
|
|
17
|
+
"@types/node": ["@types/node@24.1.0", "", { "dependencies": { "undici-types": "~7.8.0" } }, "sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w=="],
|
|
18
18
|
|
|
19
19
|
"@types/react": ["@types/react@19.1.8", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-AwAfQ2Wa5bCx9WP8nZL2uMZWod7J7/JSplxbTmBQ5ms6QpqNYm672H0Vu9ZVKVngQ+ii4R/byguVEUZQyeg44g=="],
|
|
20
20
|
|
package/package.json
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spooder",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.1.
|
|
4
|
+
"version": "5.1.5",
|
|
5
5
|
"module": "./src/api.ts",
|
|
6
6
|
"bin": {
|
|
7
7
|
"spooder": "./src/cli.ts"
|
|
8
8
|
},
|
|
9
|
+
"main": "./src/api.ts",
|
|
9
10
|
"exports": {
|
|
10
11
|
".": {
|
|
11
12
|
"bun": "./src/api.ts",
|
|
12
|
-
"import": "./src/api.ts"
|
|
13
|
+
"import": "./src/api.ts",
|
|
14
|
+
"default": "./src/api.ts"
|
|
13
15
|
}
|
|
14
16
|
},
|
|
15
17
|
"devDependencies": {
|
package/src/api.ts
CHANGED
|
@@ -1077,6 +1077,8 @@ type BootstrapCacheBust = {
|
|
|
1077
1077
|
|
|
1078
1078
|
type BootstrapOptions = {
|
|
1079
1079
|
base?: string | BunFile;
|
|
1080
|
+
drop_missing_subs?: boolean;
|
|
1081
|
+
|
|
1080
1082
|
routes: Record<string, BootstrapRoute>;
|
|
1081
1083
|
cache?: ReturnType<typeof cache_http> | CacheOptions;
|
|
1082
1084
|
|
|
@@ -1522,6 +1524,7 @@ export function http_serve(port: number, hostname?: string) {
|
|
|
1522
1524
|
if (cache !== undefined && !is_cache_http(cache))
|
|
1523
1525
|
cache = cache_http(cache);
|
|
1524
1526
|
|
|
1527
|
+
const drop_missing = options.drop_missing_subs ?? true;
|
|
1525
1528
|
for (const [route, route_opts] of Object.entries(options.routes)) {
|
|
1526
1529
|
const content_generator = async () => {
|
|
1527
1530
|
let content = await resolve_bootstrap_content(route_opts.content);
|
|
@@ -1530,7 +1533,7 @@ export function http_serve(port: number, hostname?: string) {
|
|
|
1530
1533
|
content = await parse_template(await resolve_bootstrap_content(options.base), { content }, false);
|
|
1531
1534
|
|
|
1532
1535
|
const sub_table = sub_table_merge({}, global_sub_table, route_opts.subs);
|
|
1533
|
-
content = await parse_template(content, sub_table,
|
|
1536
|
+
content = await parse_template(content, sub_table, drop_missing);
|
|
1534
1537
|
|
|
1535
1538
|
return content;
|
|
1536
1539
|
};
|