@syntaxcircus/cmsify-client 0.2.4 → 0.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/dist/index.cjs CHANGED
@@ -40,6 +40,7 @@ __export(index_exports, {
40
40
  getFormatHint: () => getFormatHint,
41
41
  isProseHint: () => isProseHint,
42
42
  listAll: () => listAll,
43
+ renderCmsifyTemplate: () => renderCmsifyTemplate,
43
44
  toMimeType: () => toMimeType
44
45
  });
45
46
  module.exports = __toCommonJS(index_exports);
@@ -310,6 +311,18 @@ function isProseHint(hint) {
310
311
  return hint === "plaintext" || hint === "markdown" || hint === "html";
311
312
  }
312
313
 
314
+ // src/templating.ts
315
+ var TOKEN_PATTERN = /\$\{\{\s*([A-Za-z][A-Za-z0-9_.-]*)\s*\}\}/g;
316
+ function renderCmsifyTemplate(template, variables) {
317
+ if (!template.includes("${{")) {
318
+ return template;
319
+ }
320
+ return template.replace(
321
+ TOKEN_PATTERN,
322
+ (full, name) => Object.prototype.hasOwnProperty.call(variables, name) ? variables[name] ?? "" : full
323
+ );
324
+ }
325
+
313
326
  // src/generated/schema.ts
314
327
  var schema_exports = {};
315
328
 
@@ -328,6 +341,7 @@ var createCmsifyFetchClient = (baseUrl, fetchImpl) => fetchImpl ? (0, import_ope
328
341
  getFormatHint,
329
342
  isProseHint,
330
343
  listAll,
344
+ renderCmsifyTemplate,
331
345
  toMimeType
332
346
  });
333
347
  //# sourceMappingURL=index.cjs.map