Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Md gilbert/ListItem
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
require('strict') local p = {} --[[ This module is intended to be invoked by the ListMaster module. Depending on the style passed to the parent, will parse and display the list item as a table row, subsection, etc. Possible values that could be used for a members table: name, role, member_since, role, status, etc Possible values that could be used for a tasks table: title, notes, page, owner, created, due, completed, priority, remaining, etc Values can be passed in that aren't displayed, allowing for more robust storage of metadata for each item (ie, any arbitrary value can be passed in that aren't intended to be displayed, but instead facilitate machine-trackable data). --]] 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 res end function p.display_name(name) return "[[User:" .. name .. "|" .. name .. "]] β’ [[User_talk:" .. name .. "|Talk]] β’ [[Special:Contributions/" .. name .. "|Contribs]]" end function p.firstToUpper(str) return (str:gsub("^%l", string.upper)) end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Md gilbert/ListItem/doc
(
edit
)