Module:Page data
From International Robin Hood Bibliography
Documentation for this module may be created at Module:Page data/doc
local p = {} local util = require 'Module:Utilities' local pageName = nil local pFrame local bra, ket, cur, lie, testing = '[[', ']]', '{{', '}}', false function p.setData(frame) pFrame = frame:getParent() local categories, properties = '', '' pageName = getFrameParam('PageName') if isValidParam(pageName) then testing = setTestState() pageName = util.ucSanitize(pageName) properties = 'Utitle=' .. pageName local idx = 1 while(idx < 11) do local cat, propname, propval = getFrameParam('Cat' .. idx), getFrameParam('PropName' .. idx), getFrameParam('PropVal' .. idx) if isValidParam(cat) or ( isValidParam(propname) and isValidParam(propval) ) then if isValidParam(cat) then categories = categories .. bra .. 'Category:' .. cat .. ket end if isValidParam(propname) and propname ~= 'Utitle' and isValidParam(propval) then properties = properties .. '|' .. bra .. propname .. '=' .. propval end idx = idx + 1 else break end end properties = cur .. '#set:' .. properties .. lie end if not testing then return frame:preprocess(properties .. categories) else return properties .. categories end end function getFrameParam(paramName) local paramVal = nil if isValidParam(paramName) then paramVal = pFrame.args[paramName] if paramVal == '' then paramVal = nil end end return paramVal end function isValidParam(param) return param ~= nil and param ~= '' end function setTestState() local test = getFrameParam('Test') local testState = false if isValidParam(test) and test == 'true' then bra = 'BRABRA' ket = 'KETKET' cur = 'CURCUR' LIE = 'LIELIE' testState = true end return testState end return p