data/sample.lua: use next instead of for loop

Each definition list item contains just a single key and the associated
value.  Using `next` to get the key/value pair is more idiomatic than
iterating over the single-element table.
This commit is contained in:
Albert Krewinkel 2017-12-27 20:07:36 +01:00
parent e19526846f
commit 3b2282c962
No known key found for this signature in database
GPG key ID: 388DC0B21F631124

View file

@ -245,10 +245,9 @@ end
function DefinitionList(items)
local buffer = {}
for _,item in pairs(items) do
for k, v in pairs(item) do
table.insert(buffer,"<dt>" .. k .. "</dt>\n<dd>" ..
table.concat(v,"</dd>\n<dd>") .. "</dd>")
end
local k, v = next(item)
table.insert(buffer, "<dt>" .. k .. "</dt>\n<dd>" ..
table.concat(v, "</dd>\n<dd>") .. "</dd>")
end
return "<dl>\n" .. table.concat(buffer, "\n") .. "\n</dl>"
end