Module:TemplateListEntry
From Soyjak Wiki, the free ensoyclopedia
Jump to navigationJump to search
| This module is rated as ready for general use. It is considered stable and may be used wherever appropriate. Improvements should be developed and tested in a sandbox before changing the live module. |
Fixes a bug in {{TemplateListEntry}} that caused /doc category links to bleed into the index page and categorize the index page erroneously.
local p = {}
function p.main(frame)
local name = frame.args[1]
local title = name and mw.title.new("Template:" .. name .. "/doc")
if title and title.redirectTarget then
title = title.redirectTarget
end
local text = title and title:getContent()
if not text then
return frame.args[2] or ""
end
text = text:gsub("<includeonly%s*>.-</includeonly%s*>", "")
text = text:gsub("<includeonly%s*>.*$", "")
local child = frame:newChild({ title = title.prefixedText, args = {} })
text = child:preprocess(text)
return child:preprocess(
'<details><summary class="expand-summary">'
.. "''Click to expand documentation''"
.. "</summary>\n__NOEDITSECTION__\n"
.. text
.. "\n</details>"
)
end
return p