I’m trying out a daily journaling note, and I’d like it to contain a list of all the notes created on that day.
If I created the page manually, I’d use something like this:
${
template.each(query[[
from index.tag("page")
where _.created.split('T')[1] == "2025-06-24"
order by _.name
]], templates.pageItem)
}
Now, if I want to include this in a template, it must generalize the day in the where clause, and it would look like something like this:
${
template.each(query[[
from index.tag("page")
where _.created.split('T')[1] == "${date.today()}"
order by _.name
]], templates.pageItem)
}
But you might see how this is wrong. When instantiating the template, silverbullet will first interpolate date.today(), and then immediately interpolate the result of the entire query, rendering a fixed list of pages (while I’d like a dynamic one, that updates every time I get back to the page, over the course of a day).
What I’d like is that the inner query be interpolated upon template instantiation, but that the outer query be copied/pasted into the page output by the template. So that if I instantiated the template today (2025-06-24), it would generate the first Lua query of this post.
To have it run in the finished page dynamically and not baked in the first time the page is created, you need to prepend ${"$"} in front of any Lua callouts.
${"$"}{
template.each(query[[
from index.tag("page")
where _.created.split('T')[1] == "${date.today()}"
order by _.name
]], templates.pageItem)
}
Having it in some form of FAQ or in some page would be nice indeed! For what it’s worth, this is where I’ve looked before asking here:
(I tried looking for a similar topic on the forum, but failed to find one; more likely because of a lack of proper keywording, rather than because of the absence of answers, I suppose.)
API/spacelua (after searching for interpolat in the docs)
(I’ve also looked at the implementation of interpolation typescript, and noticed that the code was looking for ${; I started finding a hack like obtaining the same with string concat, e.g. "$" .. "{" but it didn’t seem sufficient to achieve my goals here )
So maybe the best place would be to put this in the page template doc page?
Yeah, I agree. It’s a trick but it is asked about almost weekly @zef Again, this should be documented in FAQ. Would you mind adding a FAQ page, please, to the docs? This is definitely good first FAQ candidate…