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

Материал из Space Station 14 Вики
мНет описания правки
мНет описания правки
Строка 3: Строка 3:
function p.main(frame)
function p.main(frame)
     local args = frame.args
     local args = frame.args
     local pattern = args[1] or ""  
     local searchText = args[1] or ""


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


     if content and not content:match(pattern) then
     if not content then
        return "Нет"
    end
 
    local cleanedContent = content:gsub("{{#invoke:Поиск строк страницы|main|[^}]+}}", "")
 
    if not cleanedContent:match(searchText) then
         return "Нет"
         return "Нет"
     end
     end

Версия от 14:15, 6 марта 2025

Для документации этого модуля может быть создана страница Модуль:Поиск шаблона страницы/doc

local p = {}

function p.main(frame)
    local args = frame.args
    local searchText = args[1] or ""

    local title = mw.title.getCurrentTitle()
    local content = title:getContent()

    if not content then
        return "Нет"
    end

    local cleanedContent = content:gsub("{{#invoke:Поиск строк страницы|main|[^}]+}}", "")

    if not cleanedContent:match(searchText) then
        return "Нет"
    end

    return "Да"
end

return p