Page MenuHomeSealhub

No OneTemporary

diff --git a/src/index.ts b/src/index.ts
index 7ab22b6..ccddb9a 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,38 +1,45 @@
import { FlatTemplatable, tempstream } from "tempstream";
import { Registry } from "./registry";
import { marked } from "marked";
export * from "./component-arguments";
export * from "./component";
export * from "./registry";
export type JDDocument = Array<{
component_name: string;
args: Record<string, unknown>;
}>;
export interface JDDContext {
render_image: (path_to_image: string) => FlatTemplatable;
render_markdown: (markdown: string) => FlatTemplatable;
}
export const simpleJDDContext: JDDContext = {
render_image: (path) => /* HTML */ `<img src="file://path" />`,
render_markdown: (string) => (string ? marked.parse(string) : ""),
};
export function render(
registry: Registry,
document: JDDocument,
context: JDDContext
) {
return tempstream`${document.map(({ component_name, args }) => {
const component = registry.get(component_name);
if (!component) {
console.warn(
"Component not found in the registry: " + component_name
);
return "";
}
+ for (const arg_name in component?.getArguments()) {
+ if (!Object.prototype.hasOwnProperty.call(args, arg_name)) {
+ args[arg_name] = component
+ ?.getArguments()
+ [arg_name]?.getEmptyValue();
+ }
+ }
return component.toHTML(args, context);
})}`;
}

File Metadata

Mime Type
text/x-diff
Expires
Sat, Nov 23, 14:59 (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
547436
Default Alt Text
(1 KB)

Event Timeline