Module:Sandbox/Md gilbert/ListItem explained

require('strict')

local p =

--function p.printItem(frame) local parent_frame = frame:getParent local style = parent_frame.args.style local display = parent_frame.args.display

local res = "" if style

"table" then res = "|- \n" for col in string.gmatch(display, "[^,]+") do -- Validate the current field, make sure we have the desired value, -- setting to an empty string if the arg doesn't exist. if frame.args[col]

nil then frame.args[col] = "" end -- Then display, passing to our local functions if the argument -- is one for which we have a specialized display function if p["display_" .. col] ~= nil then res = res .. "| " .. p["display_" .. col](frame.args[col]) .. "\n" else res = res .. "| " .. frame.args[col] .. "\n" end end elseif style

"section" then local title = "ListItem" if frame.args.name ~= nil then title = frame.args.name elseif frame.args.title ~= nil then title = frame.args.title end res = "

" .. title .. "

\n" -- Then go through each of the display sections and add to res for col in string.gmatch(display, "[^,]+") do -- Validate the current field, make sure we have the desired value, -- setting to an empty string if the arg doesn't exist. if frame.args[col]

nil then frame.args[col] = "" end -- Then display each value, passing to our local functions if they exist. if p["display_" .. col] ~= nil then res = res .. "" .. p.firstToUpper(col) .. ": " .. p["display_" .. col](frame.args[col]) else res = res .. "" .. p.firstToUpper(col) .. ": " .. frame.args[col] end end end

return resend

function p.display_name(name) return "" .. name .. " • Talk • Contribs"end

function p.firstToUpper(str) return (str:gsub("^%l", string.upper))end

return p