Module:DisplayFunctions

local Functions = {}

function Functions.image(imageSize) return function(imageName) if imageName == nil or imageName == '' then return nil end return string.format('', imageName, imageSize) end end

function Functions.link(pageName) if pageName == nil or pageName == '' then return nil end return string.format('%s', pageName) end

function Functions.list(listType) return function(array) if array == nil then return nil end local List = require('Module:List') local data = List.makeListData(listType, array) return List.renderList(data) end end

function Functions.trueFalseOther(trueVal, falseVal, otherVal) return function(val) -- probably should not use == with bool, but this is more explicit if val == true then return trueVal elseif val == false then return falseVal end return otherVal end end

function Functions.yesAndNo(val) return Functions.trueFalseOther('Yes', 'No', nil)(val) end

function Functions.checkAndX(val) return Functions.trueFalseOther('✓', '✗', nil)(val) end

function Functions.pluralHeader(forms) local contentLang = mw.getContentLanguage return function(list) return contentLang:convertPlural(#(list or {}), forms) end end

return Functions