Module:SourceFilter: Difference between revisions

From Tardis Wiki, the free Doctor Who reference
No edit summary
No edit summary
Line 6: Line 6:
local outputText = ""
local outputText = ""
for count = 1, #args do
for count = 1, #args do
outputText = outputText .. "<div class=\"mw-collapsible\" id=\"mw-customcollapsible-" .. args[count] .."\">"
outputText = outputText .. "<div class=\"mw-collapsible\" id=\"mw-customcollapsible-" .. args[count] .. "\">"
end
end
util_vars.setVar("SourceHideDiv", #args)
util_vars.setVar("SourceHideDiv", #args)
return outputText
return frame:preprocess(outputText)
end
end


function p.endFilterBlock()
function p.endFilterBlock(frame)
local outputText = ""
local outputText = ""
local divs = util_vars.getVar("SourceHideDiv")
local divs = util_vars.getVar("SourceHideDiv")
Line 18: Line 18:
outputText = outputText .. "</div>"
outputText = outputText .. "</div>"
end
end
return outputText
return frame:preprocess(outputText)
end
end


return p
return p

Revision as of 21:40, 24 June 2022

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

local util_vars = require('Module:VarsUtil')
local p = {}

function p.startFilterBlock(frame)
	local args = frame:getParent().args
	local outputText = ""
	for count = 1, #args do
		outputText = outputText .. "<div class=\"mw-collapsible\" id=\"mw-customcollapsible-" .. args[count] .. "\">"
	end
	util_vars.setVar("SourceHideDiv", #args)
	return frame:preprocess(outputText)
end

function p.endFilterBlock(frame)
	local outputText = ""
	local divs = util_vars.getVar("SourceHideDiv")
	for count = 1, divs do
		outputText = outputText .. "</div>"
	end
	return frame:preprocess(outputText)
end

return p