Modul:Namespace detect: Unterschied zwischen den Versionen
better comments
(trim whitespace, just in case, tweak frame code comment) |
(better comments) |
||
| Zeile 105: | Zeile 105: | ||
-- Compare the namespace found with the parameters that have been | -- Compare the namespace found with the parameters that have been | ||
-- specified, and return the appropriate parameter. | -- specified, and return content of the appropriate parameter. | ||
local function compare() | local function compare() | ||
local namespace = getNamespace() | local namespace = getNamespace() | ||
-- First, | -- First, compare mainspace parameters. | ||
if namespace == mw.site.namespaces[0].name and args[cfg.main] then | if namespace == mw.site.namespaces[0].name and args[cfg.main] then | ||
return args[cfg.main] | return args[cfg.main] | ||
end | end | ||
-- Next, | -- Next, compare parameters for non-main namespaces. | ||
for nsid, ns in pairs( mw.site.namespaces ) do | for nsid, ns in pairs( mw.site.namespaces ) do | ||
local nsname = mw.ustring.lower( ns.name ) | local nsname = mw.ustring.lower( ns.name ) | ||
| Zeile 138: | Zeile 138: | ||
end | end | ||
-- | -- Finally, return parameters for other namespaces. This happens if | ||
-- | -- there was no text specified for the namespace that was detected | ||
-- | -- or if the demospace parameter is not a valid namespace. Note that | ||
-- the parameter for the detected namespace must be completely | |||
-- absent for this to happen, not merely blank. | |||
if args[cfg.other] then | if args[cfg.other] then | ||
return args[cfg.other] | return args[cfg.other] | ||