Module:ResourceLink
From Against the Storm Official Wiki
Documentation for this module may be created at Module:ResourceLink/doc
------------------------------------------------------------------------------- -- Renders the {{resourceLink}} template -- -- Takes an argument, the name of the resource. Optionally, accepts a second -- argument, "med" or "large" to render the icon as larger than the standard -- size of text, {{ImgS}} ------------------------------------------------------------------------------- local ResourceLink = {} local IconFilenames = require("Module:IconFilenames") -- lookup table for image filenames function ResourceLink.renderLink(frame) local strImageName = frame.args.image local strImageSize = frame.args.size local strFilename = IconFilenames.getIconFilename(strImageName) -- if looking up the provided image name returned nil, then render an error if not strFilename then return "renderIcon Error: file " .. strImageName .." not found" end -- render the string to return, starting with the file tag, then the link tag -- use the established templates for image sizes, with the default being -- small, or in-line size. local strFileSize = "{{ImgS}}" if "med" == strImageSize then strFileSize = "{{ImgM}}" elseif "large" == strImageSize then strFileSize = "{{ImgL}}" elseif "huge" == strImageSize then strFileSize = "{{ImgH}}" end local strFilePart = string.format("[[File:%s|%s]]", strFilename, strImageSize) -- build the link based on the name of the resource passed in local strLinkPart = "[[" .. strImageName .. "]]" return strFilePart .. strLinkPart end return ResourceLink