Jump to content

Module:DisplayTemplate: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
-- Module:ShowTemplateContent
--[[
-- Uses Lua to invoke the content of a template to an article without calling its categories
* 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 = {}
local p = {}
Line 11: Line 15:
      
      
     local templateContent = mw.getCurrentFrame():expandTemplate{title = templateName}
     local templateContent = mw.getCurrentFrame():expandTemplate{title = templateName}
    templateContent = templateContent:gsub("%[%[Category:[^]]+%]%]", "")
     return templateContent
     return templateContent
end
end


return p
return p

Latest revision as of 02:58, 25 August 2025

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