Module:SourceFilter: Difference between revisions
From Tardis Wiki, the free Doctor Who reference
Bongolium500 (talk | contribs) (Created page with "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 outputText end function p.endFilterBlock(frame) local args = frame:getParent().args local outputText = "" local divs = util_vars...") |
Bongolium500 (talk | contribs) (unecassary) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local outputText = "" | local outputText = "" | ||
for count = 1, | local numArgs = 0 | ||
outputText = outputText .. | for _ in pairs(args) do numArgs = numArgs + 1 end | ||
for count = 1, numArgs do | |||
outputText = outputText .. "<div class=\"mw-collapsible\" id=\"mw-customcollapsible-" .. args[count] .. "\">" | |||
end | end | ||
util_vars.setVar(SourceHideDiv, | util_vars.setVar("SourceHideDiv", numArgs) | ||
return outputText | return outputText | ||
end | end | ||
function p.endFilterBlock(frame) | function p.endFilterBlock(frame) | ||
local outputText = "" | local outputText = "" | ||
local divs = util_vars.getVar(SourceHideDiv) | local divs = util_vars.getVar("SourceHideDiv") | ||
for count = 1, divs do | for count = 1, divs do | ||
outputText = outputText .. "</div>" | outputText = outputText .. "</div>" |
Latest revision as of 09:56, 25 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 = ""
local numArgs = 0
for _ in pairs(args) do numArgs = numArgs + 1 end
for count = 1, numArgs do
outputText = outputText .. "<div class=\"mw-collapsible\" id=\"mw-customcollapsible-" .. args[count] .. "\">"
end
util_vars.setVar("SourceHideDiv", numArgs)
return outputText
end
function p.endFilterBlock(frame)
local outputText = ""
local divs = util_vars.getVar("SourceHideDiv")
for count = 1, divs do
outputText = outputText .. "</div>"
end
return outputText
end
return p