Для документации этого модуля может быть создана страница Модуль:TestCall/doc
local p = {}
p.recipes = {
{
title = "Слизь",
steps = { "Вода [4]", "Азот [1]", "Масло [10]" },
description = ""
},
{
title = "Жидкость с протеинами",
steps = { "Вода [3]", "Протеины [1]", "Жир [6]", "Кровь [20]" },
description = ""
},
{
title = "Голубая кровь",
steps = { "Вода [11]", "Сахар [2]", "Диоксид углерода [3]", "Железо [0.5]", "Протеины [4]", "Голубая кровь [20]" },
description = ""
},
{
title = "Бесцветная жидкость",
steps = { "Вода [11]", "Сахар [2]", "Медь [0.5]", "Протеины [4]", "Диоксид углерода [3]" },
description = "Бесцветная жидкость, необходимая человеку для выживания. На вид прозрачная. Утоляет жажду."
}
}
function p.renderRecipe(recipe)
local html = mw.html.create('div')
html:addClass('chem-recipe')
html:tag('div'):addClass('chem-recipe-title'):wikitext(recipe.title)
local content = html:tag('div'):addClass('chem-recipe-content')
content:tag('div'):addClass('chem-recipe-step'):wikitext("Смешайте:")
for _, step in ipairs(recipe.steps) do
content:tag('div'):addClass('chem-ingredient'):wikitext(step)
end
if recipe.description ~= "" then
content:tag('div'):wikitext(recipe.description)
end
return tostring(html)
end
function p.main()
local container = mw.html.create('div')
container:addClass('chem-container')
for _, recipe in ipairs(p.recipes) do
container:wikitext(p.renderRecipe(recipe))
end
return tostring(container)
end
return p