Модуль:Поиск шаблона страницы: различия между версиями

Материал из Space Station 14 Вики
Новая страница: «local p = {} function p.main(frame) local pageTitle = mw.title.getCurrentTitle() local content = pageTitle:getContent() if content and not content:match("строка") then return "Нет" end return "Да" end return p»
 
мНет описания правки
 
(не показано 30 промежуточных версий этого же участника)
Строка 2: Строка 2:


function p.main(frame)
function p.main(frame)
     local pageTitle = mw.title.getCurrentTitle()
     local modName = frame.args[1]
     local content = pageTitle:getContent()
    if not modName then
        return "Параметр не задан"
     end


     if content and not content:match("строка") then
    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 "Нет"
         return "Нет"
     end
     end
    return "Да"
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