This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected.
{{#invoke:Category pair|_pair|title object for first page|title object for second page}}
require('strict')localgetArgs=require('Module:Arguments').getArgslocalhatnote=require('Module:Hatnote')._hatnotelocalformatLink=require('Module:Format link')._formatLinklocalp={}localcatNS=mw.site.namespaces.Category.id-- category namespace number-- Lua implementation of [[Template:CategoryPair]]-- 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)functionp._pair(prevTitle,nextTitle)prevTitle=prevTitleandprevTitle.existsandformatLink{link=prevTitle.fullText}nextTitle=nextTitleandnextTitle.existsandformatLink{link=nextTitle.fullText}localnote=''ifprevTitleandnextTitlethen-- if bothnote=mw.ustring.format('See also the preceding %s and the succeeding %s',prevTitle,nextTitle)elseifprevTitlethen-- if only prevTitlenote=mw.ustring.format('See also the preceding %s',prevTitle)elseifnextTitlethen-- if only nextTitlenote=mw.ustring.format('See also the succeeding %s',nextTitle)else-- otherwise neitherreturnmw.title.getCurrentTitle().namespace==catNSand'[[Category:Pages using category pair with no output]]'or''endreturnhatnote(note,{extraclasses='seealso'})endfunctionp.catPair(frame)localargs=getArgs(frame,{wrappers={'Template:Category pair'}})localprevTitle=args[1]andmw.title.new(args[1],catNS)localnextTitle=args[2]andmw.title.new(args[2],catNS)returnp._pair(prevTitle,nextTitle)endfunctionp.prevCat(frame)localargs=getArgs(frame,{wrappers={'Template:Preceding category'}})localprevTitle=args[1]andmw.title.new(args[1],catNS)returnp._pair(prevTitle,nil)endfunctionp.nextCat(frame)localargs=getArgs(frame,{wrappers={'Template:Succeeding category'}})localnextTitle=args[1]andmw.title.new(args[1],catNS)returnp._pair(nil,nextTitle)endreturnp