Editing Parameters
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.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 3: | Line 3: | ||
local DEFINITIONS = { | local DEFINITIONS = { | ||
− | + | native_name = {code = "<!-- name in local language. If more than one, " .. | |
− | + | "separate using {{Plain list}} and omit native_name_lang -->"}, | |
− | + | native_name_lang = {code = "<!-- language two- or three-letter ISO code -->"}, | |
− | + | start_date = {code = "<!-- {{Start date|YYYY|MM|DD}} -->"}, | |
− | + | end_date = {code = "<!-- {{End date|YYYY|MM|DD}} -->"},} | |
− | |||
− | |||
− | |||
− | |||
− | native_name = { | ||
− | |||
− | |||
− | |||
− | |||
− | native_name_lang = { | ||
− | |||
− | |||
− | start_date = { | ||
− | |||
− | |||
− | end_date = { | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
local p = {} | local p = {} | ||
Line 40: | Line 16: | ||
return function(frame) | return function(frame) | ||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
− | return p[funcName](getArgs(frame | + | return p[funcName](getArgs(frame)) |
end | end | ||
end | end | ||
− | local function extractParams( | + | local function extractParams(source) |
− | |||
− | |||
local parameters = {} | local parameters = {} | ||
for parameter in string.gmatch(source, '{{{(.-)%f[}|<>]') do | for parameter in string.gmatch(source, '{{{(.-)%f[}|<>]') do | ||
Line 54: | Line 28: | ||
end | end | ||
− | local function | + | local function strMap(iter, transform, sort) |
local returnTable = {} | local returnTable = {} | ||
− | for | + | for _, v in pairs(iter) do |
− | returnTable | + | table.insert(returnTable, transform(v)) |
+ | end | ||
+ | if sort then | ||
+ | table.sort(returnTable) | ||
end | end | ||
− | |||
− | |||
− | |||
− | |||
− | |||
return table.concat(returnTable) | return table.concat(returnTable) | ||
end | end | ||
Line 76: | Line 48: | ||
function p._code(args) | function p._code(args) | ||
− | local definitions = yesno(args.definitions | + | local definitions = yesno(args.definitions, true) |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
local title = args._base or mw.title.getCurrentTitle().baseText | local title = args._base or mw.title.getCurrentTitle().baseText | ||
return string.format([[{{%s | return string.format([[{{%s | ||
− | %s}}]], title, strMap( | + | %s}}]], title, strMap(extractParams(args.base), |
function(s) | function(s) | ||
if definitions then | if definitions then | ||
Line 147: | Line 105: | ||
%s]], | %s]], | ||
strMap(Set.valueIntersection(baseParams, otherParams), | strMap(Set.valueIntersection(baseParams, otherParams), | ||
− | function(v) return string.format('* %s\n', v) end), | + | function(v) return string.format('* %s\n', v) end, true), |
strMap(Set.valueIntersection(baseNormParams, otherNormParams), | strMap(Set.valueIntersection(baseNormParams, otherNormParams), | ||
function(v) return string.format('* %s < %s [%s]\n', | function(v) return string.format('* %s < %s [%s]\n', | ||
Line 153: | Line 111: | ||
table.concat(otherNormParams[v], '; '), | table.concat(otherNormParams[v], '; '), | ||
v) | v) | ||
− | end), | + | end, true), |
strMap(Set.valueComplement(otherNormParams, baseNormParams), | strMap(Set.valueComplement(otherNormParams, baseNormParams), | ||
function(v) return strMap(baseNormParams[v], | function(v) return strMap(baseNormParams[v], | ||
− | function(s) return string.format('* %s\n', s) end) | + | function(s) return string.format('* %s\n', s) end, true) |
− | end)) | + | end, true)) |
end | end | ||
Line 167: | Line 125: | ||
function p._dlist(args) | function p._dlist(args) | ||
− | |||
return strMap(extractParams(args.base), | return strMap(extractParams(args.base), | ||
− | function(s) | + | function(s) return string.format('; %s: \n', s) end) |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||