Модуль:Infobox: различия между версиями
Перейти к навигации
Перейти к поиску
[непроверенная версия] | [непроверенная версия] |
Нет описания правки |
Нет описания правки |
||
Строка 103: | Строка 103: | ||
end | end | ||
-- Generates | -- Generates rows | ||
function p.rows(frame) | function p.rows(frame) | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
if args["условия"] == '' then return '' end | if args["условия"] == '' then return '' end | ||
local text = '<div class="infobox-data-table">' | local text = '<div class="infobox-header">' | ||
text = text..''..(args["метка"] or '') | |||
if yn(args.itemprop, true) then | |||
text = text..'<span style="display: none;" itemprop="'..args.itemprop..'">'..args.content..'</span>' | |||
end | |||
text = text..'</div>' | |||
text = '<div class="infobox-data-table">' | |||
text = text..'<div class="infobox-data-table-left">\n\n'..(args["значение1"] or '')..'</div>' | text = text..'<div class="infobox-data-table-left">\n\n'..(args["значение1"] or '')..'</div>' | ||
text = text..'<div class="infobox-data-table-right">\n\n'..(args["значение2"] or '')..'</div>' | text = text..'<div class="infobox-data-table-right">\n\n'..(args["значение2"] or '')..'</div>' |
Версия от 23:16, 24 декабря 2018
Этому шаблону не хватает документации. Вы можете помочь проекту, сделав описание шаблона: что он делает, как его использовать, какие параметры он принимает. Это поможет другим использовать его. Для оформления можете воспользоваться {{doc}} или {{doc-inline}}. Не забывайте помещать описание внутрь <noinclude></noinclude>. P.S. Также не забываем про категорию. |
local p = {}
local yn = require('Module:Yesno')
-- Start the infobox
function p.start(frame)
local args = frame:getParent().args
--Start the box
local text = '<div '
local itt = args.itemtype
if yn(itt, true) then
text = text..' itemscope itemtype="https://schema.org/'..itt..'" class="infobox">'
else
text = text..' class="infobox">'
end
--заголовок
if yn(args.itemprop, true) then
text = text..'<div class="infobox-title"><span itemprop="'..args.itemprop..'">'..(args["заголовок"])..'</span>'
if yn(args["примечание"], true) then
text = text..'<sup>'..args["примечание"]..'</sup>'
end
text = text..'</div>'
else
text = text..'<div class="infobox-title"><span>'..(args["заголовок"])..'</span>'
if yn(args["примечание"], true) then
text = text..'<sup>'..args["примечание"]..'</sup>'
end
text = text..'</div>'
end
--подзаголовок
if yn(args["подзаголовок"], true) then
text = text..'<div class="infobox-subtitle">'
if yn(args.itemprop2, true) then
if yn(args["язык"], true) then
text = text..frame:expandTemplate{ title = 'lang-'..args["язык"], args = {'<span itemprop="'..args.itemprop2..'">'..args["подзаголовок"]..'</span>' } }
else
text = text..'<span itemprop="'..args.itemprop2..'"><i>'..args["подзаголовок"]..'</i></span>'
end
else
if yn(args["язык"], true) then
text = text..frame:expandTemplate{ title = 'lang-'..args["язык"], args = { args["подзаголовок"] } }
else
text = text..'<span><i>'..args["подзаголовок"]..'</i></span>'
end
end
text = text..'</div>'
end
--изображение
if yn(args['изображение'], true) then
text = text..'<div class="infobox-image">'..
frame:expandTemplate{ title = 'Карточка/Tabber', args = {
args['изображение'],
size = args['размер изображения']
} }..'<span style="display: none;" itemprop="image">'..frame:callParserFunction{ name = 'filepath', args = {args['изображение'], 'nowiki'} }..'</span>'
if yn(args["описание изображения"], true) then
text = text..'<div class="infobox-caption"><span>'..args["описание изображения"]..'</span></div>'
end
text = text..'</div>'
end
return text
end
-- Generates a header
function p.header(frame)
local args = frame:getParent().args
if args["условия"] == '' then return '' end
local text = '<div class="infobox-header">'
text = text..''..(args["заголовок"] or '')
if yn(args.itemprop, true) then
text = text..'<span style="display: none;" itemprop="'..args.itemprop..'">'..args.content..'</span>'
end
text = text..'</div>'
return text
end
-- Generates a single row
function p.row(frame)
local args = frame:getParent().args
if args["условия"] == '' then return '' end
local text = '<div class="infobox-data">'
text = text..'<div class="infobox-data-label">\n\n'..(args["метка"] or '')..'</div>'
text = text..'<div class="infobox-data-value">\n\n'..(args["значение"] or '')..''
if yn(args.itemprop, true) then
text = text..'<span style="display: none;" itemprop="'..args.itemprop..'">'..args.content..'</span>'
end
if yn(args.itemprop2, true) then
text = text..'<span style="display: none;" itemprop="'..args.itemprop2..'">'..args.content2..'</span>'
end
text = text..'</div></div>'
return text
end
-- Generates rows
function p.rows(frame)
local args = frame:getParent().args
if args["условия"] == '' then return '' end
local text = '<div class="infobox-header">'
text = text..''..(args["метка"] or '')
if yn(args.itemprop, true) then
text = text..'<span style="display: none;" itemprop="'..args.itemprop..'">'..args.content..'</span>'
end
text = text..'</div>'
text = '<div class="infobox-data-table">'
text = text..'<div class="infobox-data-table-left">\n\n'..(args["значение1"] or '')..'</div>'
text = text..'<div class="infobox-data-table-right">\n\n'..(args["значение2"] or '')..'</div>'
text = text..'</div>'
return text
end
-- Collapsible boxes
function p.box(frame)
local args = frame:getParent().args
if args["условия"] == '' then return '' end
local text = '<div class="infobox-group BoxFrame '
local st = args["скрывать"]
if st == 'да' then
text = text..'collapsed">'
elseif st == 'нет' then
text = text..'">'
else
text = text..'collapsed">'
end
text = text..'<div class="infobox-header BoxHead">'..(args["метка"] or '')..'</div>'
text = text..'<div class="infobox-horizontal BoxContent"><div class="infobox-horizontal-value">'..(args["значение"] or '')..'</div></div>'
text = text..'</div>'
return text
end
-- Generates the ending part
function p.ending(frame)
return '</div>'
end
return p
--[[Category:Lua Modules]]