Jump to content

Module:Documentation: Difference between revisions

make all the helper functions available in the p table
m>Mr. Stradivarius
(make a couple of the helper functions available for testing)
m>Mr. Stradivarius
(make all the helper functions available in the p table)
Line 16: Line 16:
----------------------------------------------------------------------------
----------------------------------------------------------------------------
-- Helper functions
-- Helper functions
--
-- These are defined as local functions, but are made available in the p
-- table for testing purposes.
----------------------------------------------------------------------------
----------------------------------------------------------------------------


Line 45: Line 48:
end
end


p.message = message -- Make this function available for testing.
p.message = message


local function makeWikilink(page, display)
local function makeWikilink(page, display)
Line 54: Line 57:
end
end
end
end
p.makeWikilink = makeWikilink


local function makeCategoryLink(cat, sort)
local function makeCategoryLink(cat, sort)
local catns = mw.site.namespaces[14].name
local catns = mw.site.namespaces[14].name
return makeWikilink(catns .. '/' .. cat, sort)
return makeWikilink(catns .. ':' .. cat, sort)
end
end
p.makeCategoryLink = makeCategoryLink


local function makeUrlLink(url, display)
local function makeUrlLink(url, display)
return mw.ustring.format('[%s %s]', url, display)
return mw.ustring.format('[%s %s]', url, display)
end
end
p.makeUrlLink = makeUrlLink


local function makeToolbar(...)
local function makeToolbar(...)
Line 76: Line 85:
end
end


p.makeToolbar = makeToolbar -- Make this function available for testing.
p.makeToolbar = makeToolbar


local function err(msg)
local function err(msg)
Line 85: Line 94:
)
)
end
end
p.err = err


----------------------------------------------------------------------------
----------------------------------------------------------------------------
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.