Module:Lockbox

local export = {}

function export.lock(frame) local output = {} -- check if the current page is cascade-protected -- XXX: unfortunately there is no other way; title.protectionLevels does not report cascading protection status mw.title.getCurrentTitle:getContent -- self-transclude; see mw:Extension:Scribunto/Lua reference manual if frame:preprocess "" == "" then table.insert(output, ' Warning: this page (' .. mw.title.getCurrentTitle.fullText .. ') is not cascade-protected. \n') end local match = string.match -- transclude everything, and discard the output for _, item in ipairs(frame.args) do		item = mw.text.trim(item) -- getContent on a title object might be cleaner, but getContent and title objects -- are considered "expensive". even though they are probably cheaper than actual transclusion frame:expandTemplate { title = item }

local ns = match(item, "^(.-):") if not ns or not mw.site.namespaces[ns] then item = "Template:" .. item elseif (ns == "File") or (ns == "Image") then -- XXX: leaving this separate just in case it needs special handling item = ":" .. item elseif ns == "Category" then item = ":" .. item end table.insert(output, '* ' .. item .. '\n') end

if frame.args.silent then return "" else return table.concat(output) end end

return export