Module:Navbar: Difference between revisions
Jump to navigation
Jump to search
ArrowHead294 (talk | contribs) mNo edit summary |
ArrowHead294 (talk | contribs) mNo edit summary |
||
| (37 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
local | local getArgs = require("Module:Arguments").getArgs | ||
local yesno = require("Module:Yesno") | |||
local p = {} | local p = {} | ||
-- Main function called by navigation box templates | |||
function p._navbar(name, mode, text, namespace) | function p._navbar(name, mode, text, namespace) | ||
mode = mode or "" | mode = mode or "" | ||
text = (text == nil and "" or text .. " ") | text = (text == nil and "" or text .. " ") | ||
namespace = namespace or "Template | namespace = namespace or "Template" | ||
local p_name = string.format("%s:%s", namespace, name) | |||
local p_talk_name = string.format("%s talk:%s", namespace, name) | |||
local p_edit_name = "Special:EditPage/" .. p_name | |||
local s = " • " | |||
local links = (mode == mini and {"V", "T", "E"} or {"View", "Talk", "Edit"}) | |||
return string.format("<span style=\"font-size: 0.75em; font-weight: normal; font-style: normal;\">%s[[%s|%s]]%s[[%s|%s]]%s[[%s|%s]]</span>", | |||
text, p_name, links[1], s, p_talk_name, links[2], s, p_edit_name, links[3]) | |||
end | end | ||
-- Wrapper function for [[Template:Navbar]] | |||
function p.navbar(frame) | function p.navbar(frame) | ||
local args = getArgs(frame) | |||
local name = frame.args["name"] | local name = frame.args["name"] | ||
local namespace = frame.args["namespace"] | local namespace = frame.args["namespace"] | ||
local mode = frame.args["mode"] | local mode = frame.args["mode"] | ||
local text = frame.args["text"] | local text = frame.args["text"] | ||
local wtext = yesno(frame.args["wtext"] or args["wtext"]) | |||
local result = p._navbar(name, mode, text, namespace) | |||
-- Debugger option | |||
if wtext then | |||
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" | |||
end | end | ||
return frame:preprocess(result) | |||
end | end | ||
return p | return p | ||
Latest revision as of 19:12, 17 December 2025
- This module implements a metatemplate, and may be invoked by templates using its corresponding template Template:Navbar, or used directly from other modules.
This module is used by Template:Navbar to generate View/Talk/Edit links on templates.
To include this module in other modules, use local navbar = require("Module:Navbar")._navbar.
| Introspection summary for Module:Navbar | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| ||||||||||||||||||
No function descriptions were provided. The Lua code may have further information.
local getArgs = require("Module:Arguments").getArgs
local yesno = require("Module:Yesno")
local p = {}
-- Main function called by navigation box templates
function p._navbar(name, mode, text, namespace)
mode = mode or ""
text = (text == nil and "" or text .. " ")
namespace = namespace or "Template"
local p_name = string.format("%s:%s", namespace, name)
local p_talk_name = string.format("%s talk:%s", namespace, name)
local p_edit_name = "Special:EditPage/" .. p_name
local s = " • "
local links = (mode == mini and {"V", "T", "E"} or {"View", "Talk", "Edit"})
return string.format("<span style=\"font-size: 0.75em; font-weight: normal; font-style: normal;\">%s[[%s|%s]]%s[[%s|%s]]%s[[%s|%s]]</span>",
text, p_name, links[1], s, p_talk_name, links[2], s, p_edit_name, links[3])
end
-- Wrapper function for [[Template:Navbar]]
function p.navbar(frame)
local args = getArgs(frame)
local name = frame.args["name"]
local namespace = frame.args["namespace"]
local mode = frame.args["mode"]
local text = frame.args["text"]
local wtext = yesno(frame.args["wtext"] or args["wtext"])
local result = p._navbar(name, mode, text, namespace)
-- Debugger option
if wtext then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
return frame:preprocess(result)
end
return p