spooder 5.1.3 → 5.1.4

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 (3) hide show
  1. package/README.md +8 -0
  2. package/package.json +1 -1
  3. 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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "spooder",
3
3
  "type": "module",
4
- "version": "5.1.3",
4
+ "version": "5.1.4",
5
5
  "module": "./src/api.ts",
6
6
  "bin": {
7
7
  "spooder": "./src/cli.ts"
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, true);
1536
+ content = await parse_template(content, sub_table, drop_missing);
1534
1537
 
1535
1538
  return content;
1536
1539
  };