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

Материал из Space Station 14 Вики
мНет описания правки
мНет описания правки
 
(не показано 29 промежуточных версий этого же участника)
Строка 2: Строка 2:


function p.main(frame)
function p.main(frame)
     local args = frame.args
     local modName = frame.args[1]
     local pattern = args[1] or ""  
    if not modName then
        return "Параметр не задан"
    end
 
     local title = mw.title.getCurrentTitle()
    if not title then
        return "Не удалось получить заголовок страницы"
    end


     local pageTitle = mw.title.getCurrentTitle()
     local content = title:getContent() or ""
    local content = pageTitle:getContent()


     if content and not content:match(pattern) then
    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