In v1 have the next query in all daily notes to track unfinish task:
task
where done = false and itags = "daily"
render [[Library/Core/Query/Task]]
I have problems try to convert them to v2
Any help is apreciate
In v1 have the next query in all daily notes to track unfinish task:
task
where done = false and itags = "daily"
render [[Library/Core/Query/Task]]
I have problems try to convert them to v2
Any help is apreciate
Something like this?
${query[[
from index.tag "task"
where not done and table.includes(itags, "daily")
]]}
lochel has provided a working version (didn’t test it but the principle holds). I think it would be beneficial for the understanding to see the below explicit version which shows how space lua is integrated into the query.
${
query[[
from t = index.tag "task"
where not t.done and table.includes(t.itags, "daily")
]]
}
A least this version shows me where the done and itags comes from therefore it is easier for me to understand where I can extend. if you don’t want to explicitly define the t
variable in from
statement you can also use _.done
in where
statement. You are free to use any lua helper functions in where
statement that is within scope and eventually eval to true
or false
.
Thank you very much, it works perfectly, to make it the same format I have after i adapted the query a little:
${template.each(query[[from t = index.tag “task” where not t.done and table.includes(t.itags, “daily”)]], templates.taskItem)}
Just found a problem with my solution, i use the query in my daily note “template” and the problem is if use the template.each the query is inserted to the note directly and no in query format. But if i don’t use the template.each i don’t have the links to the task and obtain a table result.
A work-around for escaping expressions to be embedded into templates was documented recently:
Note that you can have the text {lua expression} in your page and it won’t be evaluated. So writing
${"$"}{lua expression}
can be used to “delay” evaluation by one pass, for example to escape expressions in templated content.
Thanks very much, is working now perfectly.