Module:Details

De Wikisisar
Révision datée du 21 octobre 2017 à 20:59 par TDLaouer (discussion | contributions) (1 révision importée)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)
Aller à : navigation, rechercher

La documentation pour ce module peut être créée à Module:Details/doc

--[[
-- This module produces a "For more details on this topic" link. It implements
-- the {{details}} template.
--]]

local mHatnote = require('Module:Hatnote')
local mHatlist = require('Module:Hatnote list')
local mArguments -- lazily initialise
local mTableTools -- lazily initialise
local p = {}

function p.details (frame)
	mArguments = require('Module:Arguments')
	mTableTools = require('Module:TableTools')
	local args = mArguments.getArgs(frame, {parentOnly = true})
	local topic, category = args.topic, args.category
	local options = {selfref = args.selfref}
	args = mTableTools.compressSparseArray(args)
	if #args == 0 then
		return mHatnote.makeWikitextError(
			'no page name specified',
			'Template:Details#Errors',
			category
		)
	end
	return p._details(args, topic, options)
end

function p._details (list, topic, options)
	list = mHatlist.andList(list, true)
	topic = topic or 'this topic'
	local text = string.format('For more details on %s, see %s.', topic, list)
	return mHatnote._hatnote(text, options)
end

return p