24,539 ARTICLES
ON THIS WIKI

Module:NavItem

Lua Logo.svg This is the Lua module for Template:NavItem. Below is the documentation for that template.

This template is used to show items in navboxes.

Syntax[edit]

Type {{NavItem|<NameOfItem>|<OptionalImage>|<OptionalLink>}} in navboxes.

Examples[edit]

{{NavItem|<Blood Altar>}}

gives…

Blood Altar Blood Altar

See also[edit]


local p = {}

local g = require("Module:Common")
local s = require("Module:Sprite")

function p.makeNavItem(name, image, link, text)
	name = name or "Unknown"
	image = image or ("Grid " .. name .. ".png")
	link = link or name
	text = text or name
	
	local out = '<span class="navitem">'
	out = out .. g.img(image, "16px", link, text)
	out = out .. "&nbsp;"
	out = out .. g.link(link, text)
	out = out .. "</span>"
	
	return out
end

function p.makeSpriteNavItem(name, spriteSheet, spriteIdx, link, text)
	name = name or "Unknown"
	link = link or name
	text = text or name
	
	local out = '<span class="navitem">'
	out = out .. s.makeSprite(spriteSheet, spriteIdx, 16, 256, link, text, nil)
	out = out .. "&nbsp;"
	out = out .. g.link(link, text)
	out = out .. "</span>"
	
	return out
end

function p.makeCssSpriteNavItem(name, spriteSheet, spriteIdx, link, text)
	name = name or "Unknown"
	link = link or name
	text = text or name
	
	local out = '<span class="navitem"><span class="ni ni'
	out = out .. (spriteIdx + 1)
	out = out .. "\">"
	out = out .. g.link(link, " ")
	out = out .. "</span>&nbsp;"
	out = out .. g.link(link, text)
	out = out .. "</span>"
	
	return out
end

function p.main(frame)
	local frame, args = g.getFrameAndArgs(frame)
	
	return p.makeNavItem(args[1], args[2], args[3], args.text)
end

return p