Dantes (обсуждение | вклад) Нет описания правки |
Dantes (обсуждение | вклад) Нет описания правки |
||
| Строка 11: | Строка 11: | ||
local backgroundColor = args["ЦветФона"] or "#f9f9f9" | local backgroundColor = args["ЦветФона"] or "#f9f9f9" | ||
local function | local function joinBlock(text, separator) | ||
local items = {} | local items = {} | ||
for item in mw.text.gsplit(text, ";") do | for item in mw.text.gsplit(text, ";") do | ||
table.insert(items, | table.insert(items, mw.text.trim(item)) | ||
end | end | ||
return table.concat(items, | return table.concat(items, separator) | ||
end | end | ||
local html = {} | local html = {} | ||
table.insert(html, '<div style="border: 2px solid ' .. borderColor .. '; padding: 1em; border-radius: 8px; background: ' .. backgroundColor .. '; max-width: | table.insert(html, '<div style="border: 2px solid ' .. borderColor .. '; padding: 1em; border-radius: 8px; background: ' .. backgroundColor .. '; max-width: 500px;">') | ||
table.insert(html, '<h3 style="margin-top:0;">' .. title .. '</h3>') | table.insert(html, '<h3 style="margin-top:0;">' .. title .. '</h3>') | ||
table.insert(html, "<b>Рецепт:</b>< | table.insert(html, "<b>Рецепт:</b><br>") | ||
table.insert(html, | table.insert(html, joinBlock(ingredients, " + ") .. ' → ' .. joinBlock(result, " + ")) | ||
table.insert(html, "<b> | table.insert(html, "<br><br><b>Эффекты:</b><ul>") | ||
for item in mw.text.gsplit(effects, ";") do | |||
table.insert(html, "<li>" .. mw.text.trim(item) .. "</li>") | |||
end | |||
table.insert(html, "</ul>") | table.insert(html, "</ul>") | ||
Версия от 10:46, 16 мая 2025
Для документации этого модуля может быть создана страница Модуль:AlchemyRecipe/doc
local p = {}
function p.card(frame)
local args = frame:getParent().args
local title = args["Название"] or "Без названия"
local ingredients = args["Ингредиенты"] or ""
local result = args["Результат"] or ""
local effects = args["Эффекты"] or ""
local borderColor = args["ЦветРамки"] or "#ccc"
local backgroundColor = args["ЦветФона"] or "#f9f9f9"
local function joinBlock(text, separator)
local items = {}
for item in mw.text.gsplit(text, ";") do
table.insert(items, mw.text.trim(item))
end
return table.concat(items, separator)
end
local html = {}
table.insert(html, '<div style="border: 2px solid ' .. borderColor .. '; padding: 1em; border-radius: 8px; background: ' .. backgroundColor .. '; max-width: 500px;">')
table.insert(html, '<h3 style="margin-top:0;">' .. title .. '</h3>')
table.insert(html, "<b>Рецепт:</b><br>")
table.insert(html, joinBlock(ingredients, " + ") .. ' → ' .. joinBlock(result, " + "))
table.insert(html, "<br><br><b>Эффекты:</b><ul>")
for item in mw.text.gsplit(effects, ";") do
table.insert(html, "<li>" .. mw.text.trim(item) .. "</li>")
end
table.insert(html, "</ul>")
table.insert(html, "</div>")
return table.concat(html, "\n")
end
return p