Jump to content

Module:Pagination/previous

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Codemini (talk | contribs) at 05:36, 6 July 2025 (extensionTag). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}
local getArgs = require('Module:Arguments').getArgs
local function err(msg)
           return mw.ustring.format('<strong class="error">%s ([[Template:Pagination#Errors|help]])</strong>', msg)
end
function p.getPreviousButton(frame)
           local args = getArgs(frame) -- for templates only
           return p._getPreviousButton(args)
end

function p._getPreviousButton(args) -- for modules only
           link = args[1] or args.link
           style = args.style or "background-color: blue;"
  if link then
     return mw.ustring.format(mw.getCurrentFrame():extensionTag('templatestyles', {src='Module:Pagination/style.css'}) .. '<span class="prev-btn" style="%s;">[[:%s|Previous]]</span>', style, link)
  elseif not link then
     return err('PaginationScriptError: parameter for the previous button link not found, got: nil')
  elseif link == '' then
     return err('PaginationScriptError: a link must be provided for the previous button')
  end
end

return p