「模組:See also」:修訂間差異
imported>DC (建立內容為「--[[ -- This module produces a "See also: a, b and c" link. It implements the -- template {{see also}}. --]] local mHatnote = require('Module:Hatnote') local mTa…」的新頁面) |
imported>DC 無編輯摘要 |
||
第27行: | 第27行: | ||
if not pages[1] then | if not pages[1] then | ||
return mHatnote.makeWikitextError( | return mHatnote.makeWikitextError( | ||
' | '未指定頁面名稱', | ||
'Template:See also# | 'Template:See also#錯誤', | ||
args.category | args.category | ||
) | ) | ||
第40行: | 第40行: | ||
function p._seeAlso(options, ...) | function p._seeAlso(options, ...) | ||
local altphrase = options and options.altphrase or ' | local altphrase = options and options.altphrase or '參見' | ||
local links = mHatnote.formatPageTables(...) | local links = mHatnote.formatPageTables(...) | ||
links = mw.text.listToText(links) | links = mw.text.listToText(links) |
於 2021年8月3日 (二) 12:43 的最新修訂
可在模組:See also/doc建立此模組的說明文件
--[[
-- This module produces a "See also: a, b and c" link. It implements the
-- template {{see also}}.
--]]
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(
'未指定頁面名稱',
'Template:See also#錯誤',
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 '參見'
local links = mHatnote.formatPageTables(...)
links = mw.text.listToText(links)
local text = altphrase .. ':' .. links
-- Pass options through.
local hnOptions = {}
hnOptions.selfref = options.selfref
hnOptions.extraclasses = 'rellink boilerplate seealso noprint'
return mHatnote._hatnote(text, hnOptions)
end
return p