Module:Icon

-- (prevents literal interpretation of links or categories within the module code) -- Lua Templating for supporting Template:Icon. local p = {} local cargo = mw.ext.cargo

-- Usage: function p.Wyrmprint(frame) local name = mw.text.decode(frame.args[1], true) local wyrmprint = cargoQuery{ tables = 'Wyrmprints', fields = '_pageName,BaseId,Name', args = { where = '_pageName="'..name..'" OR Name="'..name..'"', groupBy = '_pageName', limit = 1 } }[1] -- We only want the first result

if wyrmprint == nil then return ..name.. end

-- Format the content local pageName = wyrmprint['_pageName'] local baseId = wyrmprint['BaseId']

local link = valueIfNotEmpty(frame.args['link']) or pageName local size = valueIfNotEmpty(frame.args['size']) or '80px' local text = frame.args['text'] == '1' local thumbnail = ''

if text then return thumbnail..' '..wyrmprint['Name']..'' else return thumbnail end end

-- Helper functions function cargoQuery(args) return cargo.query(args.tables, args.fields, args.args) end

-- Returns the string if it's not empty, otherwise returns false function valueIfNotEmpty(s) if (s == nil or s == '') then return false else return s end end

return p --