Jump to content

Module:DisplayTemplate

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

--[[
* Name: DisplayTemplate
* Author: Mark W. Datysgeld
* Description: Template content display without category invocation, useful for documentation and debugging
* Notes: Uses frame:expandTemplate to render template content, then strips all category links with pattern matching
]]

local p = {}

function p.showTemplate(frame)
    local templateName = frame.args[1]
    if not templateName then
        return "Error: No template name provided."
    end
    
    local templateContent = mw.getCurrentFrame():expandTemplate{title = templateName}
    templateContent = templateContent:gsub("%[%[Category:[^]]+%]%]", "")
    return templateContent
end

return p