Модуль:Инфобокс/bulleted block

Википедия — эркенаб энциклопедия сайталдасан материал

Для документации этого модуля может быть создана страница Модуль:Инфобокс/bulleted block/doc

local p = {}

-- takes strings or nils; returns a string
function makeText(frame, text, wikidata, from)
	if wikidata and wikidata ~= ''then
		return frame:expandTemplate{title='Wikidata', args={wikidata, text or '', from=from or ''}}
	else
		return text or ''
	end
end

function p.main(frame)
	local args = frame:getParent().args
	
	local texts = {}
	for i = 1, 20 do -- TODO
		if args['текст' .. i] then
			texts[i] = makeText(frame, args['текст' .. i], args['викибаянал' .. i], args['from'])
		end
	end
	
	local textsAreEmpty = true
	for i = 1, 20 do -- TODO
		if texts[i] and texts[i] ~= '' then
			textsAreEmpty = false
		end
	end
	
	local results = {}
	if not textsAreEmpty and args['гъоркьбетӀер'] and args['гъоркьбетӀер'] ~= '' then
		results['текст1'] = args['гъоркьбетӀер']
		results['стил_текст1'] = 'padding-bottom:0; border-bottom:0; font-weight:bold;'
	end
	
	local mainText = makeText(frame, args['текст'], args['викибаянал'], args['from'])
	if mainText == '' and args['гӀаламат'] and args['гӀаламат'] ~= '' and not textsAreEmpty then
		mainText = ' '
	end
	
	if mainText and mainText ~= '' then
		results['гӀаламат2'] = args['гӀаламат']
		results['стил_гӀаламат2'] = 'padding-bottom:0; border-bottom:0;text-align:left;'
		results['текст2'] = mainText
		results['стил_текст2'] = 'padding-bottom:0; border-bottom:0;text-align:left;'
	end
	
	for i = 1, 20 do --TODO
		if texts[i] and texts[i] ~= '' then
			results['гӀаламат' .. (i+2)] = ' • ' .. (args['гӀаламат' .. i] or '')
			results['текст' .. (i+2)] = texts[i]
			
			local last = true
			for j = i+1, 20 do -- TODO
				if texts[j] and texts[j] ~= '' then
					last = false
				end
			end
			
			if last then
				results['стил_гӀаламат' .. (i+2)] = 'font-weight:normal; padding-top:0; border-top:0;text-align:left;'
				results['стил_текст' .. (i+2)] = 'padding-top:0; border-top:0; text-align:left;'
			else
				results['стил_гӀаламат' .. (i+2)] = 'font-weight:normal; padding-bottom:0; border-bottom:0; padding-top:0; border-top:0;text-align:left;'
				results['стил_текст' .. (i+2)] = 'padding-bottom:0; border-bottom:0; padding-top:0; border-top:0;text-align:left;'
			end
		end
	end

	return frame:expandTemplate{title='Инфобокс/блок', args=results}
end

return p