Jump to content

Module:Pagination/previous

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by Codemini (talk | contribs) at 13:44, 6 July 2025 (Use the css color). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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 ";"
  if link then
     return mw.ustring.format(mw.getCurrentFrame():extensionTag('templatestyles', {src='Module:Pagination/styles.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