Lua: better handle nil, null and undefined values for Lua directives

pull/1219/merge
Zef Hemel 2025-02-10 20:30:28 +01:00
parent 5b982ac257
commit 7abb096382
2 changed files with 5 additions and 9 deletions

View File

@ -66,14 +66,10 @@ export class LuaWidget extends WidgetType {
this.client.currentPage,
);
activeWidgets.add(this);
if (!widgetContent) {
div.innerHTML = "";
this.client.setWidgetCache(
this.cacheKey,
{ height: div.clientHeight, html: "" },
);
return;
if (widgetContent === null || widgetContent === undefined) {
widgetContent = { markdown: "nil" };
}
let html = "";
if (typeof widgetContent !== "object") {
// Return as markdown string or number
@ -98,7 +94,7 @@ export class LuaWidget extends WidgetType {
} else {
// If there is a markdown key, use it, otherwise render the objects as a markdown table
let mdContent = widgetContent.markdown;
if (!mdContent) {
if (mdContent === undefined) {
mdContent = await renderExpressionResult(widgetContent);
}
let mdTree = parse(

View File

@ -2,5 +2,5 @@ This is the start of the standard library distributed as part of SilverBullet co
${template.each(query[[
from index.tag "page"
where name:startsWith("Library/Std")
where name:startsWith("Library/Std/")
]], templates.pageItem)}