primate 0.27.2 → 0.27.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "primate",
3
- "version": "0.27.2",
3
+ "version": "0.27.4",
4
4
  "description": "Polymorphic development platform",
5
5
  "homepage": "https://primatejs.com",
6
6
  "bugs": "https://github.com/primatejs/primate/issues",
package/src/app.js CHANGED
@@ -151,12 +151,17 @@ export default async (log, root, config) => {
151
151
  return this.path.build.join(...directories);
152
152
  },
153
153
  async render({ body, head }, page = config.pages.index, placeholders = {}) {
154
+ ["body", "head"].every(used => is(placeholders[used]).undefined());
154
155
  const { assets, config: { location, pages } } = this;
155
156
 
156
- return to({ ...placeholders, body, head: render_head(assets, head) })
157
+ return to(placeholders)
158
+ // replace given placeholders, defaulting to ""
157
159
  .reduce((html, [key, value]) => html.replace(`%${key}%`, value ?? ""),
158
160
  await index(this.runpath(location.pages), page, pages.index))
159
- .replaceAll(/%.*%/gus, "");
161
+ // replace non-given placeholders, aside from %body% / %head%
162
+ .replaceAll(/(?<keep>%(?:head|body)%)|%.*?%/gus, "$1")
163
+ // replace body and head
164
+ .replace("%body%", body).replace("%head%", render_head(assets, head));
160
165
  },
161
166
  async inline(code, type) {
162
167
  const integrity = await this.hash(code);
package/src/dispatch.js CHANGED
@@ -17,6 +17,9 @@ export default (patches = {}) => (object, raw, cased = true) => {
17
17
 
18
18
  return object[cased ? property : property.toLowerCase()];
19
19
  },
20
+ json() {
21
+ return JSON.parse(JSON.stringify(object));
22
+ },
20
23
  toString() {
21
24
  return JSON.stringify(object);
22
25
  },