Модуль:Песочница/Pok: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 1: | Строка 1: | ||
local p = {} | local p = {} | ||
local getArgs = require('Module:Arguments').getArgs | |||
function p.main(frame) | function p.main(frame) | ||
local args = frame | local args = getArgs(frame, { removeBlanks = false }) | ||
local name = args[1] or args[ | local name = args[1] or "" | ||
local attributes = args[2] or "" | |||
if name == "" then | if name == "" then | ||
return "<span class=\"error\">Ошибка: не указано имя файла.</span>" | return "<span class=\"error\">Ошибка: не указано имя файла.</span>" | ||
| Строка 15: | Строка 17: | ||
if include_base then | if include_base then | ||
local t = mw.title.new(" | local t = mw.title.new("Файл:" .. name .. "." .. ext) | ||
if t and t.exists then | if t and t.exists then | ||
table.insert(found, "") | table.insert(found, "") | ||
| Строка 22: | Строка 24: | ||
for i = 1, max do | for i = 1, max do | ||
local t = mw.title.new(" | local t = mw.title.new("Файл:" .. name .. "-" .. i .. "." .. ext) | ||
if t and t.exists then | if t and t.exists then | ||
table.insert(found, "-" .. i) | table.insert(found, "-" .. i) | ||
| Строка 33: | Строка 35: | ||
local before = "[[" .. namespace .. ":" .. name | local before = "[[" .. namespace .. ":" .. name | ||
local after = "." .. ext .. "]]" | local after = "." .. ext .. "" .. attributes .. "]]" | ||
local parts = {} | local parts = {} | ||