跳转到内容

模組:PageList

被永久保护的模块
维基百科,自由的百科全书

这是本页的一个历史版本,由Cwek留言 | 贡献2017年7月18日 (二) 08:09编辑。这可能和当前版本存在着巨大的差异。

local pl={}
local getArgs

local SPLIT="、"
local LASTSPLIT="和"
local LIMIT=20

pl.main=function(frame)
	if not getArgs then
		getArgs = require('Module:Arguments').getArgs
	end
	local args = getArgs(frame, {parentFirst=true})
	local curPage_obj=mw.title.getCurrentTitle()
	args["nspace"]=args["nspace"] or curPage_obj.nsText
	
	return pl._main(args)
end

pl._main=function(args)
	local delim=args["delim"] 
	local edelim=args["edelim"] or delim
	local NS=args["nspace"]
	mw.log(delim)
	mw.log(edelim)
	mw.log(NS)
	
	local out={}
	for i=1,LIMIT do
		local curVal,nextVal=args[i],args[i+1]
		if i~=1 then table.insert(out,(nextVal==nil and LASTSPLIT) or SPLIT) end
		if curVal~=nil then table.insert(out,mw.ustring.format("%s[[:%s%s]]%s",delim,((NS=="" and "") or (NS..":")),curVal,edelim)) end
		if nextVal==nil then break end
	end
	return table.concat(out,"")
end
return pl