Шаблон:Флагификация/Ниноцминда: различия между версиями

Материал из Энциклопедия автомобильных номеров мира
Перейти к навигации Перейти к поиску
/>Dmitry89
(1 версия импортирована: все-модули-русской-википедии-2)
(Перемещение 28 интервики на Викиданные, d:q5845132)
Строка 1: Строка 1:
{{nobr|{{Флагификация|Антигуа и Барбуда}}}}<noinclude>
local p = {}


[[Категория:Шаблоны:Флаги по коду|{{PAGENAME}}]]
-- используется для того, чтобы можно было удалять элементы из таблицы
local function copy(other)
local res = {}
for k,v in pairs(other) do
res[k] = v
end
return res
end


[[als:Vorlage:ATG]]
-- вызов шаблона, при ошибке возвращает пустую строку
[[ast:Plantía:ATG]]
local function expand(frame, tname, targs)
[[az:Şablon:ATG]]
local success, result = pcall(
[[bar:Vorlage:ATG]]
frame.expandTemplate,
[[be-x-old:Шаблён:ATG]]
frame,
[[bg:Шаблон:ATG]]
{title = tname, args = targs}
[[bn:টেমপ্লেট:ATG]]
)
[[br:Patrom:Antigua]]
if success then
[[de:Vorlage:ATG]]
return result
[[el:Πρότυπο:ATG]]
else
[[en:Template:ATG]]
return ''
[[eo:Ŝablono:ATG]]
end
[[es:Plantilla:ATG]]
--return frame:expandTemplate({title = tname, args = args})
[[eu:Txantiloi:ATG]]
end
[[fa:الگو:ATG]]
 
[[fi:Malline:Antigua ja Barbuda]]
function p.main(frame)
[[fr:Modèle:Antigua-et-Barbuda]]
if not getArgs then
[[frr:Vorlage:ATG]]
getArgs = require('Module:Arguments').getArgs
[[gl:Modelo:ATG]]
end
[[hu:Sablon:Antigua és Barbuda]]
yesno = require('Module:Yesno')
[[hy:Կաղապար:ATG]]
local trim = not (yesno(frame:getParent().args.trim or frame:getParent().args._trim, false) == false) -- по умолчанию true
[[id:Templat:ATG]]
local args = copy(getArgs(frame, {trim = trim, removeBlanks = false})) --copy(frame.args)
[[io:Shablono:ATG]]
local tname = args.t or args._t or args.template or args._template
[[is:Snið:ATG]]
local opener = args.opener or args._opener
[[it:Template:ATG]]
local sep = args.sep or args._sep
[[ja:Template:ATG]]
local prefix = args.prefix or args._prefix
[[ko:틀:ATG]]
local postfix = args.postfix or args._postfix
[[lb:Schabloun:ATG]]
local style = args.style or args._style
[[lv:Veidne:ATG]]
local nobr = args.nobr or args._nobr
[[nah:Nemachiyōtīlli:ATG]]
local nocat = args.nocat or args._nocat
[[nl:Sjabloon:AG]]
local spaced = args.spaced or args._spaced
[[nn:Mal:ATG]]
local comment_sep = args.comment_sep or args._comment_sep
[[pam:Template:ATG]]
local between = args.between or args._between
[[pt:Predefinição:ATG]]
local inthemiddle = yesno(args.inthemiddle or args._inthemiddle, false)
[[qu:Plantilla:ATG]]
local wide = yesno(args.wide or args._wide, false)
[[ro:Format:ATG]]
if not opener then
[[simple:Template:ATG]]
if style == 'wikitable' then
[[sl:Predloga:ATG]]
opener = '|-\n| '
[[th:แม่แบบ:ATG]]
elseif style == 'pre' or style == '*pre' or style == 'pre↓' or style == '*pre↓' then
[[tr:Şablon:ATG]]
opener = ''
[[uk:Шаблон:ATG]]
if between == nil and (style == '*pre' or style == '*pre↓') then
[[ur:سانچہ:ATG]]
between = '<div style="margin-top:3em"></div>' -- содержимое шаблона {{^|3em}}
[[vec:Modèl:ATG]]
end
[[vi:Bản mẫu:ATG]]
else
[[zh:Template:ATG]]
opener = '* '
</noinclude>
end
end
if between == nil and (style == 'pre' or style == '*pre' or style == 'pre↓' or style == '*pre↓') then
between = '<div style="margin-top:2em"></div>' -- содержимое шаблона {{^|2em}}
end
if tname == '' or tname == nil then -- при отсутствующем имени шаблона берём его из названия страницы
tname = mw.language.new('ru'):lcfirst(mw.title.getCurrentTitle().rootText)
end
local content, are_comments, i = '', false, 0
for k, v in pairs(args) do
local pre_targs, targs = {}, {}
if type(k) == 'number' then
i = i + 1
if v ~= '' then
pre_targs = mw.text.split(v, '\\')
for k2, v2 in pairs(pre_targs) do
equals_pos = nil
if v2:sub(1, 1) == '_' and v2:find('=') then -- параметры настроек шаблона "пример"
equals_pos = v2:find('=')
end
if equals_pos then
param = v2:sub(1, equals_pos-1)
value = v2:sub(equals_pos+1)
targs[param] = value
if param == '_comment' then are_comments = true end
else
if v2:sub(1, 5) == '&#95;' then
targs[k2] = v2:gsub('&#95;', '_')
else
targs[k2] = v2
end
end
end
end
table.insert(targs, 1, tname)
targs._sep, targs._style, targs._nobr, targs._nocat, targs._spaced, targs._comment_sep, targs._prefix, targs._postfix
= sep, style, nobr, nocat, spaced, comment_sep, prefix, postfix
local adjusted_opener
if style == 'pre' and opener == '*' and targs._before == nil then
adjusted_opener = ''
targs._style = '*pre'
else
adjusted_opener = opener
end
--[[if not targs._style then
targs._style = style
end]]
content = content .. (i ~= 1 and (between and between .. '\n' or '\n') or '') .. adjusted_opener .. tostring(expand(frame, 'пример', targs))
end
end
if style == 'wikitable' then
local table_content = ''
if not inthemiddle then
table_content = '{| class="wikitable '
if wide then table_content = table_content .. 'wide' end
table_content = table_content .. '"\n! Код !! Результат'
if are_comments then table_content = table_content .. ' !! Комментарий' end
end
content = table_content .. '\n' .. content
if not inthemiddle then
content = content .. '\n|}'
end
end
return content
end
 
return p

Версия от 13:47, 6 июня 2015

local p = {}

-- используется для того, чтобы можно было удалять элементы из таблицы local function copy(other) local res = {} for k,v in pairs(other) do res[k] = v end return res end

-- вызов шаблона, при ошибке возвращает пустую строку local function expand(frame, tname, targs) local success, result = pcall( frame.expandTemplate, frame, {title = tname, args = targs} ) if success then return result else return end --return frame:expandTemplate({title = tname, args = args}) end

function p.main(frame) if not getArgs then getArgs = require('Module:Arguments').getArgs end yesno = require('Module:Yesno') local trim = not (yesno(frame:getParent().args.trim or frame:getParent().args._trim, false) == false) -- по умолчанию true local args = copy(getArgs(frame, {trim = trim, removeBlanks = false})) --copy(frame.args) local tname = args.t or args._t or args.template or args._template local opener = args.opener or args._opener local sep = args.sep or args._sep local prefix = args.prefix or args._prefix local postfix = args.postfix or args._postfix local style = args.style or args._style local nobr = args.nobr or args._nobr local nocat = args.nocat or args._nocat local spaced = args.spaced or args._spaced local comment_sep = args.comment_sep or args._comment_sep local between = args.between or args._between local inthemiddle = yesno(args.inthemiddle or args._inthemiddle, false) local wide = yesno(args.wide or args._wide, false) if not opener then if style == 'wikitable' then opener = '|-\n| ' elseif style == 'pre' or style == '*pre' or style == 'pre↓' or style == '*pre↓' then opener = if between == nil and (style == '*pre' or style == '*pre↓') then

between = '

' -- содержимое шаблона

end else opener = '* ' end end if between == nil and (style == 'pre' or style == '*pre' or style == 'pre↓' or style == '*pre↓') then

between = '

' -- содержимое шаблона

end

if tname == or tname == nil then -- при отсутствующем имени шаблона берём его из названия страницы tname = mw.language.new('ru'):lcfirst(mw.title.getCurrentTitle().rootText) end

local content, are_comments, i = , false, 0 for k, v in pairs(args) do local pre_targs, targs = {}, {} if type(k) == 'number' then i = i + 1

if v ~= then pre_targs = mw.text.split(v, '\\') for k2, v2 in pairs(pre_targs) do equals_pos = nil if v2:sub(1, 1) == '_' and v2:find('=') then -- параметры настроек шаблона "пример" equals_pos = v2:find('=') end if equals_pos then param = v2:sub(1, equals_pos-1) value = v2:sub(equals_pos+1) targs[param] = value if param == '_comment' then are_comments = true end else if v2:sub(1, 5) == '_' then targs[k2] = v2:gsub('_', '_') else targs[k2] = v2 end end end end

table.insert(targs, 1, tname) targs._sep, targs._style, targs._nobr, targs._nocat, targs._spaced, targs._comment_sep, targs._prefix, targs._postfix = sep, style, nobr, nocat, spaced, comment_sep, prefix, postfix local adjusted_opener if style == 'pre' and opener == '*' and targs._before == nil then adjusted_opener = targs._style = '*pre' else adjusted_opener = opener end --[[if not targs._style then targs._style = style end]]

content = content .. (i ~= 1 and (between and between .. '\n' or '\n') or ) .. adjusted_opener .. tostring(expand(frame, 'пример', targs)) end end if style == 'wikitable' then local table_content = if not inthemiddle then table_content = '{| class="wikitable ' if wide then table_content = table_content .. 'wide' end table_content = table_content .. '"\n! Код !! Результат' if are_comments then table_content = table_content .. ' !! Комментарий' end end content = table_content .. '\n' .. content if not inthemiddle then content = content .. '\n|}' end end

return content end

return p