If I create a listing of all tasks like so:
${template.each(query[[
from index.tag("task")
]], templates.taskItem)}
Any tasks with custom state are rendered like this:
* NOT STARTED page@123 task text
I.e., the task state box is never rendered, so I can’t change it from this listing. Tasks that just have default “checked/unchecked” state do render a checkbox, but it doesn’t link back to the checkbox on the original page.
This behavior is the same even if I render this task listing via a widget:
function tasks_widget()
local content = ""
for task in query[[from index.tag("task")]] do
content = content .. string.format("* [%s] %s\n", task.state, task.name)
end
return widget.new(content)
end
${tasks_widget()}
However, if I create a virtual page in approximately the same manner:
virtualPage.define({
pattern="all_tasks",
run = function()
local content = ""
for task in query[[from index.tag("task")]] do
content = content .. string.format("* [%s] %s\n", task.state, task.name)
end
return content
end
})
All the tasks show up correctly and toggling state changes the state in the page where the task was defined. Why can’t tasks that are “embedded” on a page render correctly and have state changes link back to the original page?
On a somewhat related note, I see lots of errors where the client is trying to open a “real” page for my virtual all_tasks page (i.e., GET https://host:port/.fs/all_tasks.md). Shouldn’t Silverbullet ignore whatever it’s doing (syncing changes?) when the user is on a virtual page?