Модуль рэалізуе шаблон }.
Модуль залежыць ад наступных іншых модуляў: |
Гэты модуль ужывае стылі: |
Дакументацыя ёсць на старонцы шаблона.
Каб пазбегнуць паломак старонак, дзе ўжыты гэты модуль, пажадана эксперыментаваць у пясочніцы для модуляў.
local p = {}; local yesno = require('Module:Yesno') local function _renderLine( frame, args, i ) if args[ 'загаловак' .. i ] and args[ 'загаловак' .. i ] == '-' then return '' elseif args[ 'загаловак' .. i ] and args[ 'загаловак' .. i ] ~= '' then local style = ( args[ 'стыль_загалоўкаў' ] or '' ) .. ( args[ 'стыль_загалоўка' .. i ] or '' ); local class = ( args[ 'клас' .. i ] or '' ); return '\n\n.. style .. '">' .. args[ 'загаловак' .. i ] .. ' \n '; end if args[ 'блок' .. i ] and args[ 'блок' .. i ] ~= '' then return args[ 'блок' .. i ]; end local text = args[ 'тэкст' .. i ] or ''; if (args[ 'вікідадзеныя' .. i ] and args[ 'вікідадзеныя' .. i ] ~= '') or (args[ 'вікіданыя' .. i ] and args[ 'вікіданыя' .. i ] ~= '') then text = frame:expandTemplate{ title = 'Wikidata', args = { args[ 'вікідадзеныя' .. i ] or args[ 'вікіданыя' .. i ], text, from = args[ 'from' ] or '' } }; end if text ~= '' then local label = args[ 'метка' .. i ] or ''; local class = args[ 'клас' .. i ] or ''; if string.find(class, 'noplainlist') == nil and string.find(class, 'nofirstlevel') == nil then class = class .. ' plainlist'; end if class ~= '' then class = ' class="duhoc-be ' .. class .. '"'; end local style = ( args[ 'стыль_тэкстаў' ] or '' ) .. ( args[ 'стыль_тэксту' ] or '' ) .. ( args[ 'стыль_тэксту' .. i ] or '' ); if label == '' then style = 'text-align:center;' .. style; end if style ~= '' then style = ' style="' .. style .. '"'; end if label ~= '' then local labelClass = args[ 'клас_метак' ] or ''; if string.find(labelClass, 'noplainlist') == nil and string.find(labelClass, 'nofirstlevel') == nil then labelClass = labelClass .. ' plainlist'; end if labelClass ~= '' then labelClass = ' class="duhoc-be ' .. labelClass .. '"'; end local labelStyle = ( args[ 'стыль_метак' ] or '' ) .. ( args[ 'стыль_меткі' .. i ] or '' ); if labelStyle ~= '' then labelStyle = ' style="' .. labelStyle .. '"'; end return '\n\n .. labelClass .. labelStyle .. '>' .. label .. ' ' .. '\n .. class .. style .. '>\n' .. text .. ' \n '; end return '\n\n .. class .. style .. '>\n' .. text .. ' \n '; end return ''; end local function maxNumber ( args ) local maxNumber = 0 for argName, _ in pairs(args) do local argNumber = mw.ustring.match(argName, '^[^0-9]+([0-9]+)$') if argNumber and tonumber(argNumber) > maxNumber then maxNumber = tonumber(argNumber) end end return maxNumber end function p.renderLine( frame ) local args = frame:getParent().args; return _renderLine(frame, args, '') end function p.renderLines( frame ) local args = frame:getParent().args; local res = '' local header, text = '', '' local autoHeaders = yesno(args [ 'аўтазагалоўкі' ] or 'false', false) for i = 0, maxNumber(args) do if args[ 'загаловак' .. i ] and args[ 'загаловак' .. i ] ~= '' then if text ~= '' or not autoHeaders then if (args[ 'клас' .. i] ~= 'infobox-medals') then res = res .. header .. text else res = res .. text end end header, text = _renderLine(frame, args, i), '' else text = text .. _renderLine(frame, args, i) end end if text ~= '' or not autoHeaders then if (args[ 'клас' .. maxNumber(args)] ~= 'infobox-medals') then res = res .. header .. text else res = res .. text end end return res end return p;