Module:Variables

-- -- Module that provides an interface with mw:Extension:Variables -- You can use this to pass variables between modules/invokes -- local var = {} --- Define a variable -- -- @param varname Name of the var to declare -- @param value  Value of the new var, if not provided, assumes the empty string function var.define( varname, value ) if not varname then return end if value == nil then value = '' else value = tostring(value) end mw.getCurrentFrame:preprocess('') end --- Get a variable -- -- @param varname     Name of the variable to get -- @param defaultvalue Default value in case the variable is not yet defined -- @return string function var.get( varname, defaultvalue ) if not varname then return '' end if defaultvalue then defaultvalue = '|' .. tostring(defaultvalue) else defaultvalue = '' end return tostring( mw.getCurrentFrame:preprocess('') ) end --- Check if a variable exists -- -- @param varname Name of the variable to check -- @return boolean function var.exists( varname ) if not varname then return false end local res = tostring( mw.getCurrentFrame:preprocess('') ) return res == '1' and true or false end return var