Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Party name with color
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!
-- This module implements [[Template:Party name with color]] local p = {} local fetch = nil -- lazy load local function load_political_party_module() if fetch == nil then fetch = require('Module:Political party')._fetch end end local function page_exist(page_name) if not page_name then return false end if mw.title.new(page_name).exists then return true end return false end local function simplify_rowspan(text) text = mw.ustring.gsub(text or '', 'rowspan="1"%s*', '') return text end function p._cell(args) if not args[1] then return '' end local display_name = nil if args.dab then display_name = args[1] elseif args.full then display_name = mw.ustring.gsub(args[1], '%s+%b()$', '') elseif args.shortname then display_name = args.shortname else load_political_party_module() display_name = fetch({args[1], 'shortname'}) end local text = nil if args.no_link then text = display_name else -- TODO: should this be on by default or do we want red links? if page_exist(args[1]) then text = string.format("[[%s|%s]]", args[1], display_name) else text = display_name end end local color = args.colour or args.color if not color then load_political_party_module() color = fetch({args[1], 'color'}) end local line1 = 'rowspan="%s" style="width: 2px; background-color: %s;" data-sort-value="%s" |\n' local line2 = '| scope="row" rowspan="%s" style="text-align: left;" | %s' local rowspan = tonumber(args.rowspan) or 1 line1 = string.format(line1, rowspan, color, args[1]) line2 = string.format(line2, rowspan, text) return simplify_rowspan(line1 .. line2) end function p.cell(frame) local getArgs = require('Module:Arguments').getArgs local args = getArgs(frame) local check = require('Module:Check for unknown parameters')._check local tracking = check({ ['unknown']='[[Category:Pages using Party name with color with unknown parameters|_VALUE_ ]]', ['preview']='Page using [[Template:Party name with color]] with unknown parameter "_VALUE_"', ['showblankpositional']='1', '1', 'color', 'colour', 'dab', 'full', 'no_link', 'rowspan', 'shortname' }, frame:getParent().args) return p._cell(args) .. tracking 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)
Templates used on this page:
Template:Lua
(
edit
)
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Template:Sandbox other
(
edit
)
Module:Arguments
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:Party name with color/doc
(
edit
)
Module:String
(
edit
)
Module:Yesno
(
edit
)