Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Infobox road/length/sandbox
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} local concat = table.concat local insert = table.insert local format = mw.ustring.format local frame = mw.getCurrentFrame() function p._length(num, args) local km = args["length_km" .. num] or '' local mi = args["length_mi" .. num] or '' local nmi = args["length_nmi" .. num] or '' local ref = args["length_ref" .. num] or '' local notes = args["length_notes" .. num] or '' if mi == '' and km == '' and nmi == '' then return nil -- none of these set, abandon end local first, unit, unit2, unit3 -- if nmi ~= '0' and mi == '' and km == '' then if tonumber (nmi) then first = nmi unit = "nmi" unit2 = "km mi" unit3 = "km mi" -- elseif mi ~= '0' and km == '' then elseif tonumber (mi) then first = mi unit = "mi" unit2 = "km" unit3 = "m" -- elseif km ~= '0' and mi == '' then elseif tonumber (km) then first = km unit = "km" unit2 = "mi" unit3 = "mi ft" else return nil -- something other than numbers so abandon end if not first then return nil end -- if mi == '' and km == '' and nmi == '' then -- return nil -- elseif notes ~= '' and first < '1' then if notes ~= '' and first < '1' then return frame:expandTemplate{ title = 'cvt', args = { first, unit, unit3, disp = "x", ref .. " ("}} .. ")<div>" .. notes .. "</div>" elseif notes == '' and first < '1' then return frame:expandTemplate{ title = 'cvt', args = { first, unit, unit3, disp = "x", ref .. " ("}} .. ")" elseif notes ~= '' then return frame:expandTemplate{ title = 'cvt', args = { first, unit, unit2, disp = "x", ref .. " ("}} .. ")<div>" .. notes .. "</div>" else return frame:expandTemplate{ title = 'cvt', args = { first, unit, unit2, disp = "x", ref .. " ("}} .. ")" end end function p.length(frame) local pframe = frame:getParent() local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself local args = pframe.args -- the arguments passed TO the template, in the wikitext that transcludes the template local num = config.num or '' return p._length(num, args) end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Infobox road/length/sandbox/doc
(
edit
)