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:
parent
e19526846f
commit
3b2282c962
1 changed files with 3 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue