Modul:See also

S Wikipedije, slobodne enciklopedije

Dokumentaciju za ovaj modul možete napraviti na stranici Modul:See also/dok

--[[
-- This module produces a "See also: a, b, and c" link. It implements the
-- template {{see also}}.
--]]

local mHatnote = require('Modul:Hatnote')
local mHatlist = require('Modul:Hatnote list')
local mArguments -- lazily initialise
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local p = {}

function p.seeAlso(frame)
	mArguments = require('Modul:Arguments')
	local args = mArguments.getArgs(frame, {parentOnly = true})
	local pages = {}
	for k, v in pairs(args) do
		if type(k) == 'number' then
			local display = args['oznaka ' .. k] or args['o' .. k]
			local page = display and
				string.format('%s|%s', string.gsub(v, '|.*$', ''), display) or v
			pages[#pages + 1] = page
		end
	end
	if not pages[1] then
		return mHatnote.makeWikitextError(
			'niste naveli stranicu',
			'Šablon:Također pogledajte#Greške',
			args.kategorija
		)
	end
	local options = {
		selfref = args.selfref
	}
	return p._seeAlso(pages, options)
end

function p._seeAlso(args, options)
	checkType('_seeAlso', 1, args, 'table')
	checkType('_seeAlso', 2, options, 'table', true)
	options = options or {}
	local list = mHatlist.andList(args, true)
	local text = string.format('Također pogledajte: %s', list)
	-- Pass options through.
	local hnOptions = {
		selfref = options.selfref
	}
	return mHatnote._hatnote(text, hnOptions)
end

return p