Module:See also: Difference between revisions

From RabastorWiki
Jump to navigation Jump to search
m (1 revision)
(No difference)

Revision as of 13:08, 18 June 2015

--[[ -- This module produces a "See also: a, b and c" link. It implements the -- template Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory. --]]

local mHatnote = require('Module:Hatnote') local mTableTools -- lazily initialise local mArguments -- lazily initialise

local p = {}

function p.seealso(frame) mTableTools = require('Module:TableTools') mArguments = require('Module:Arguments') local args = mArguments.getArgs(frame, {parentOnly = true}) local pages = {} for k, v in pairs(args) do if type(k) == 'number' then local numstring = tostring(k) local display = args['label ' .. numstring] or args['l' .. numstring] local page = {v, display} pages[k] = page end end pages = mTableTools.compressSparseArray(pages) if not pages[1] then return mHatnote.makeWikitextError( 'no page names specified', 'Template:See also#Errors', args.category ) end local options = { altphrase = args.altphrase, selfref = args.selfref } return p._seealso(options, unpack(pages)) end

function p._seealso(options, ...) local altphrase = options and options.altphrase or 'See also' local links = mHatnote.formatPageTables(...) links = mw.text.listToText(links) local text = altphrase .. ': ' .. links

-- Pass options through. local hnOptions = {} hnOptions.selfref = options.selfref

return mHatnote._hatnote(text, hnOptions) end

return p