Jump to content

Module:Pagination

From Simple English Wikipedia, the free encyclopedia
Revision as of 15:49, 1 June 2025 by Codemini (talk | changes) (Preferably good formmating)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Implements {{Pagination}}


local p = {}
local function makeWikitextError(msg)
 return error(string.format('PaginationScriptError: "%s" ([[template:Pagination#Errors|help]])', msg), 2)
end
function p.pagination(frame)
args = frame.args
prevbtn = args[1]
nextbtn = args[2]
prevcolor = args.prevcolor or ''
nextcolor = args.nextcolor or ''
p = '<span class="prev-btn" style="background-color:' .. prevcolor .. '";>[[' .. prevbtn .. '|Previous]]</span>'
n = '<span class="next-btn" style="background-color:' .. nextcolor .. '";>[[' .. nextbtn .. '|Next]]</span>'
pntm = '' .. p .. ' ' .. n .. ''
if prevbtn and nextbtn == '' then
return makeWikitextError('no link provided for the previous and next buttons') else return pntm
end
if prevbtn == '' or prevbtn == nil then
return makeWikitextError('no link provided for the previous button') else return pntm
end
end
return p