Is there a way to have a query template print a number sequence? I.e.
- First
- Second
- Third
Is there a way to have a query template print a number sequence? I.e.
I did it by copying the template.each function into my namespace and adding the existing iterator count to the render context object:
function asmw.each(tbl, fn)
local result = {}
for i, item in ipairs(tbl) do
item._i = i
table.insert(result, fn(item))
end
return table.concat(result)
end
I can then use a template like:
asmw.testItem = template.new([==[${_i}. ${ref}]==])