Модуль:Поиск шаблона страницы: различия между версиями
Материал из Space Station 14 Вики
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| (не показано 6 промежуточных версий этого же участника) | |||
| Строка 1: | Строка 1: | ||
local p = {} | local p = {} | ||
function p.main(frame) | function p.main(frame) | ||
local | local modName = frame.args[1] | ||
if not modName then | |||
return "Параметр не задан" | |||
if | |||
return " | |||
end | end | ||
local title = mw.title.getCurrentTitle() | local title = mw.title.getCurrentTitle() | ||
if not title then | |||
if not | return "Не удалось получить заголовок страницы" | ||
return " | |||
end | end | ||
local | local content = title:getContent() or "" | ||
local pattern = " | local pattern = "[\n]%s*{{" .. modName | ||
if string.match("\n" .. content, pattern) then | |||
if | return "Да" | ||
else | |||
return "Нет" | return "Нет" | ||
end | end | ||
end | end | ||
return p | return p | ||
Текущая версия от 04:13, 15 апреля 2025
Для документации этого модуля может быть создана страница Модуль:Поиск шаблона страницы/doc
local p = {}
function p.main(frame)
local modName = frame.args[1]
if not modName then
return "Параметр не задан"
end
local title = mw.title.getCurrentTitle()
if not title then
return "Не удалось получить заголовок страницы"
end
local content = title:getContent() or ""
local pattern = "[\n]%s*{{" .. modName
if string.match("\n" .. content, pattern) then
return "Да"
else
return "Нет"
end
end
return p