Lua: better handle nil, null and undefined values for Lua directives
parent
5b982ac257
commit
7abb096382
|
@ -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(
|
||||
|
|
|
@ -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)}
|
Loading…
Reference in New Issue