PC Gaming Shelter
An archive dedicated to preserving PC Gaming history and more

Module:Link

From PC Gaming Shelter

Documentation for this module may be created at Module:Link/doc

local utils = require( 'Module:Utils' )

local p = {}

local function propertiesPlan()
	return {
		['URL'] 	   = {'Has URL'},
		['Link text']  = {'Has link text'},
		['Link group'] = {'Belongs to group'}
	}
end

function p.main(frame)
	local args = frame:getParent().args
	local propMap = propertiesPlan()
	local props = utils.setProperties(propMap, args) or {}
	mw.smw.subobject(props)

	local url = args['URL'] or nil
	local label = args['Link text'] or nil
	local link = ''	
	if label and url then
		link = string.format('<li>[%s %s]</li>', url, label)
	end
	
	return link
end

return p