Hi Zef.
This is the best note taking tool I’ve come across, and its fantastic to see you interacting with folks here so often.
Thank you.
Hi Folks. Does anyone know how I’d call the attribute of a specific page in a template?
##Usecase
Currently I have an attribute called relation, which is a list of other pages, using an Each I have a list of links to those pages.
{{#each@npc in Relations}}
[[{{@npc}}]]
{{/each}}
I would like to go from" [[@npc]] " to “[[@npc]] at [[@npc.Location]]” but I can’t seem to figure out how to reference the Location attribute on the linked page from the current page.
If I understand you correctly, something like this could work.
{{#let @relations = Relations}}
{{#each @npc in {page where name in @relations}}}
[[{{@npc.name}}]] at {{@npc.Location}}
{{/each}}
{{/let}}
You have to actually query the page object using the string name from the Attribute
But I would recommend you use space-lua from now on, the solution would look similar
function showRelations(currentPage)
local npcs = query[[
from page = index.tag("page")
where table.includes(currentPage.Relations, page.name)
limit 3
]]
for i,v in ipairs(npcs) do
npcs[i] = string.format("%s at %s", v.name, v.Location)
end
return npcs
end
And you can embed it like this ${showRelations (_CTX.currentPage)}