Bước tới nội dung

Mô đun:Category pair

Bách khoa toàn thư mở Wikipedia
require('strict')local getArgs = require('Module:Arguments').getArgslocal hatnote = require('Module:Hatnote')._hatnotelocal formatLink = require('Module:Format link')._formatLinklocal p = {}local catNS = mw.site.namespaces.Category.id -- category namespace number-- Lua implementation of [[Bản mẫu:Cặp thể loại]]-- Arguments:--   prevTitle -- mw.title.Title object for preceding category--   nextTitle -- mw.title.Title object for succeeding category-- Returns:--   hatnote that says "see also" for one or both of prev/next (depending on whether they exist)function p._pair(prevTitle, nextTitle)	prevTitle = prevTitle and prevTitle.exists and formatLink{link = prevTitle.fullText}	nextTitle = nextTitle and nextTitle.exists and formatLink{link = nextTitle.fullText}	local note = ''	if prevTitle and nextTitle then -- if both		note = mw.ustring.format('Xem thêm thể loại trước %s và thể loại sau %s',prevTitle, nextTitle)	elseif prevTitle then -- if only prevTitle		note = mw.ustring.format('Xem thêm thể loại trước %s', prevTitle)	elseif nextTitle then -- if only nextTitle		note = mw.ustring.format('Xem thêm thể loại sau %s', nextTitle)	else                  -- otherwise neither		return mw.title.getCurrentTitle().namespace == catNS and '[[Thể loại:Trang sử dụng cặp thể loại không có đầu ra]]' or ''	end	return hatnote(note, {extraclasses = 'seealso'})endfunction p.catPair(frame)	local args = getArgs(frame, {wrappers={'Bản mẫu:Cặp thể loại'}})	local prevTitle = args[1] and mw.title.new(args[1],catNS)	local nextTitle = args[2] and mw.title.new(args[2],catNS)	return p._pair(prevTitle, nextTitle)endfunction p.prevCat(frame)	local args = getArgs(frame, {wrappers={'Bản mẫu:Thể loại trước'}})	local prevTitle = args[1] and mw.title.new(args[1], catNS)	return p._pair(prevTitle, nil)endfunction p.nextCat(frame)	local args = getArgs(frame, {wrappers={'Bản mẫu:Thể loại sau'}})	local nextTitle = args[1] and mw.title.new(args[1], catNS)	return p._pair(nil, nextTitle)endreturn p