跳转到内容

模組:Main/main

维基百科,自由的百科全书

这是本页的一个历史版本,由Cwek留言 | 贡献2015年10月7日 (三) 03:45 建立内容为“--这是给T:Main,T:See also等类似模板使用改进mainLua模组的类型定义文件 local t={} function t.build(pframe,pages) local curren...”的新页面)编辑。这可能和当前版本存在着巨大的差异。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)
--这是给T:Main,T:See also等类似模板使用改进mainLua模组的类型定义文件
local t={}

function t.build(pframe,pages)
	local currentTitle = mw.title.getCurrentTitle()
	local firstPageTable = pages[1]
	local firstPage
	if firstPageTable then
		firstPage = firstPageTable[1]
	else
		firstPage = currentTitle.text
		firstPageTable = {firstPage}
		pages[1] = firstPageTable
	end

	-- Find the pagetype.
	local firstPageNs = mHatnote.findNamespaceId(firstPage)
	local pagetype = firstPageNs == 0 and '条目' or '页面'
	
	-- Build the text.
	local currentNs = currentTitle.namespace
	local isCategoryNamespace = currentNs - currentNs % 2 == 14
	local stringToFormat
	if isCategoryNamespace then
		stringToFormat = '此[[Wikipedia:頁面分類|分类]]的主%s是%s'
	else
		stringToFormat = '主%s:%s'
	end
	local text = string.format(stringToFormat, pagetype, links)
end

function t.limit()
	return 10
end

function t.limitWarnString(pframe)
	return  "<span class=\"error\">(在模板"+frame:expandTemplate{title="tl",args={"main"}}+"中使用了太多的参数)</span>"
end

return t