« get me outta code hell

infra, test: expose "native" slots opt for quickEvaluate - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-06-13 12:36:24 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-06-13 12:36:59 -0300
commitf8d1e6ee6e27e5539d50191b94a79d1fcb797939 (patch)
tree30f9081a1dd6122581c555c2e7a07906145566df /src
parentfe0ebbb7aae5576492e8aa675fe5a538727bd9e5 (diff)
infra, test: expose "native" slots opt for quickEvaluate
Diffstat (limited to 'src')
-rw-r--r--src/content-function.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/content-function.js b/src/content-function.js
index d4cc3dbc..18092707 100644
--- a/src/content-function.js
+++ b/src/content-function.js
@@ -450,6 +450,7 @@ export function quickEvaluate({
 
   name,
   args = [],
+  slots = null,
   multiple = null,
   postprocess = null,
 }) {
@@ -462,6 +463,7 @@ export function quickEvaluate({
         ...opts,
         name: opts.name ?? name,
         args: opts.args ?? args,
+        slots: opts.slots ?? slots,
         postprocess: opts.postprocess ?? postprocess,
       }));
   }
@@ -560,11 +562,15 @@ export function quickEvaluate({
     slotResults[slot] = runContentFunction(flatRelationSlots[slot]);
   }
 
-  const topLevelResult = runContentFunction(root);
+  let topLevelResult = runContentFunction(root);
 
-  if (postprocess !== null) {
-    return postprocess(topLevelResult);
-  } else {
-    return topLevelResult;
+  if (slots) {
+    topLevelResult.setSlots(slots);
+  }
+
+  if (postprocess) {
+    topLevelResult = postprocess(topLevelResult);
   }
+
+  return topLevelResult;
 }