跳转到内容

模組:Distinguish/sandbox

本页使用了标题或全文手工转换
维基百科,自由的百科全书

这是本页的一个历史版本,由Qqkuro66541留言 | 贡献2019年6月8日 (六) 10:04 建立内容为“local mHatnote = require('Module:Hatnote') local mHatlist = require('Module:Hatnote list') local mArguments --initialize lazily local mTableTools --…”的新页面)编辑。这可能和当前版本存在着巨大的差异。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)
local mHatnote = require('Module:Hatnote')
local mHatlist = require('Module:Hatnote list')
local mArguments --initialize lazily
local mTableTools --initialize lazily
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local p = {}

function p.distinguish(frame)
	mArguments = require('Module:Arguments')
	mTableTools = require('Module:TableTools')
	local args = mTableTools.compressSparseArray(mArguments.getArgs(frame))
	local text = args.text or args.t
	return p._distinguish(args, text, args.selfref)
end

function p._distinguish(args, text, selfref)
	checkType("_distinguish", 1, args, 'table')
	if #args == 0 and not text then
		return mHatnote.makeWikitextError(
			'沒有指定頁面名稱或文檔',
			'Template:Distinguish#Errors'
		)
	end
	local text = string.format(
		'[[File:Confusion grey.svg|24px|link=Wikipedia:消歧义]]   &#160;<strong>提示</strong>:本條目的主題不是%s.',
		text or mHatlist.orList(args, true)
	)
	local hnOptions = {selfref = selfref}
	return mHatnote._hatnote(text, hnOptions)
end

return p