मॉड्यूल:Flag
This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. |
इस साँचे का इस्तेमाल कई बड़ी संख्या के पृष्ठों में किया जा रहा है। बड़े पैमाने पर व्यवधान और अनावश्यक सर्वर लोड से बचने के लिए, किसी भी बदलाव के पहले इस साँचे के /प्रयोगपृष्ठ उपपृष्ठ या अपने उपयोगकर्ता स्थान पर उसे जांच कर देख ले। जांचे गये बदलावों को इस साँचे में एक बार में जोड़ा जा सकता है।अन्य उपयोगकर्ताओं के खातिर, बदलाव करने से पहले उससे सम्बंधित बात-चीत वार्ता पृष्ठ पर करें। |
This module depends on the following other modules: |
Lua-native alternative to popular flag templates. Can be used to reduce post-expand include size of pages with lots of templates, since it avoids calling multilevel templates.
Usage
संपादित करें- {{flag}} → {{#invoke:flag|}}
- {{flagcountry}} → Module:flag (talk · · hist · links · doc · subpages · tests (results))
- {{flagdeco}} → Module:flag (talk · · hist · links · doc · subpages · tests (results))
- {{flagicon}} → Module:flag (talk · · hist · links · doc · subpages · tests (results))
- {{flag+link}} → Module:flag (talk · · hist · links · doc · subpages · tests (results))
- {{flagathlete}} → Module:flag (talk · · hist · links · doc · subpages · tests (results))
- {{flagmedalist}} → Module:flag (talk · · hist · links · doc · subpages · tests (results))
Examples
संपादित करें! colspan=3| Template !! colspan=3| Module
|-
! Code !! Output !! PEIS !! Code !! Output !! PEIS
|-
| {{flag|CHN}}
|| CHN || 443b || {{#invoke:flag||CHN}}
|| CHN || 128b
|-
| {{flagcountry|CHN}}
|| चीन || 577b || {{#invoke:flag|country|CHN}}
|| चीन || 128b
|-
| {{flagdeco|CHN}}
|| || 452b || {{#invoke:flag|deco|CHN}}
|| || 107b
|-
| {{flagicon|CHN}}
|| || 548b || {{#invoke:flag|icon|CHN}}
|| || 117b
|-
| {{flag+link|History of|CHN}}
|| साँचा:Flag+link || 663b || {{#invoke:flag|+link|History of|CHN}}
|| चीन || 139b
|-
| {{flagathlete|Andy Murray|GBR}}
|| साँचा:Country data GBR || 617b || {{#invoke:flag|athlete|Andy Murray|GBR}}
|| Andy Murray (GBR) || 210b
|-
| {{flagmedalist|Andy Murray|GBR}}
|| साँचा:Flagmedalist || 469b || {{#invoke:flag|medalist|Andy Murray|GBR}}
|| Andy Murray
ग्रेट ब्रिटेन || 129b
|}
local margs = require('Module:Arguments')
local function _main(frame, name, mode)
local categories = {
['Flag icon'] = '[[Category:Flag icons missing country data templates]]',
['Flag decoration'] = '[[Category:Flag decoration missing country data templates]]',
}
local yesno = require('Module:Yesno')
--Get input arguments
local args = margs.getArgs(frame, {
frameOnly = ((frame.args.frameonly or '') ~= ''), valueFunc =
function(key,value)
if value then
value = mw.text.trim(value)
--Change empty string to nil for all args except 'image' and 'border'
if key=="image" or key=="border" or value~="" then
return value
end
end
return nil
end
} )
local preftext = ""
if name == 'Flag+link' then
args.pref = args[1]
elseif name == 'Flag athlete' then
args.preftext = args[1]
args[2] = args.code or args[2] or ""
args.variant = args.variant or args[3]
elseif name == 'Flag medalist' then
preftext = (args[1] or "") .. "<br/>"
args[2] = args.code or args[2] or ""
args.variant = args.variant or args[3]
elseif name == 'Flag link' then
args.suff = args[2]
args[2] = args[1] or ""
args.variant = args.variant or args[3]
else
sports = {fb = 'fb', ['fb-rt'] = 'fb', fbicon = 'fb', ru = 'ru'}
if sports[name] then
args.avar = sports[name]
if name == 'fb' and yesno(args.align) == true then
args.align='c'
end
end
args.variant = args.variant or args[2]
args[2] = args[1] or ""
end
args[1] = mode .. (args.opts or '')
args.missingcategory = categories[name]
args.noredlink = args.noredlink or 'notext'
if args.placeholder and yesno(args.placeholder) ~= true then
args[1] = args[1] .. 'o'
end
if mw.title.getCurrentTitle().namespace == 0 then
local unknown = '[[Category:Pages using ' .. mw.ustring.lower(name) ..
' template with unknown parameters|_VALUE_' .. frame:getParent():getTitle() .. ']]'
else
local unknown = ''
end
check = ''
if name == 'Flag icon' then
local opts = {
unknown=unknown,
preview='Page using [[Template:' .. name .. ']] with unknown parameter "_VALUE_"',
ignoreblank='y',
'1','2','variant','image','size','sz','border','align','al','width',
'w','alt','ilink','noredlink','missingcategory','name','clink','link',
'pref','suff','plink','the','section','altvar','avar','age','nalign',
'nal','text','nodata','opts','placeholder','getParent','frameonly'
}
check = require('Module:Check for unknown parameters')._check(opts,args)
end
return preftext .. require('Module:Flagg').luaMain(frame,args) .. check
end
local p = {
[''] = function (frame) return _main(frame, 'Flag', 'unc' ) end,
decoration = function (frame) return _main(frame, 'Flag decoration', 'uxx' ) end,
icon = function (frame) return _main(frame, 'Flag icon', 'cxxl' ) end,
link = function (frame) return _main(frame, 'Flag link', 'unpe' ) end,
['+link'] = function (frame) return _main(frame, 'Flag+link', 'unpefo') end,
country = function (frame) return _main(frame, 'Flag country', 'unce' ) end,
athlete = function (frame) return _main(frame, 'Flag athlete', 'unape' ) end,
medalist = function (frame) return _main(frame, 'Flag medalist', 'unce' ) end,
fb = function (frame) return _main(frame, 'fb', 'unpe' ) end,
['fb-rt'] = function (frame) return _main(frame, 'fb-rt', 'unpre' ) end,
fbicon = function (frame) return _main(frame, 'fbicon', 'pxxl' ) end,
ru = function (frame) return _main(frame, 'ru', 'unpe' ) end,
IOC = function (frame) return require('Module:Country_alias').flagIOC(frame:newChild{ title = 'Template:Flag IOC' }) end,
IOC2 = function (frame) return require('Module:Country_alias').flagXYZ(frame:newChild{ title = 'Template:Flag IOC 2', args = {name = margs.getArgs(frame).name or '', type = 'name'} }) end,
IOCathlete = function (frame) return require('Module:Country_alias').flagXYZ(frame:newChild{ title = 'Template:Flag IOC athlete', args = {type = 'athlete-O'} }) end,
}
p['deco'] = p.decoration
p['IOC 2'] = p.IOC2
p['IOC athlete'] = p.IOCathlete
return p