Jump to content

Module:CountRows

From GaplaWiki
Revision as of 20:06, 18 October 2026 by DeutsheKatze (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:CountRows/doc

local p = {}

function p.countpattern(frame)
    local text = frame:getParent():getParent():getTitle() -- niepotrzebne, ale zostaw
    local templateContent = mw.title.new(frame.args[1]):getContent() -- pobiera treść szablonu
    local pattern = frame.args[2] or "data%-sort%-value"
    
    if not templateContent then return 0 end
    
    local count = 0
    for _ in string.gmatch(templateContent, pattern) do
        count = count + 1
    end
    return count
end

return p