Module:RefDetail

Une page de Wikiversité.
Sauter à la navigation Sauter à la recherche

-- This Module:RefDetail can extend any re-use of a ref like<ref name="refname"/>
-- with some detail in the same style.
-- It is used by Modèle:RefDetail for easier writing.
-- example : initial ref<ref name="ABC">referal book</ref>
-- and anywhere in the same page {{RefDetail|ABC|p.123}}
-- direct module use {{#invoke:RefDetail|ref|ABC|p.123}}

local p = {}

function p.ref(frame)
	local args_invoke = frame.args
	local args_template = frame:getParent().args
	local refname, reftxt = "", ""
	if args_invoke and args_invoke[1] then refname = args_invoke[1] or refname end
	if args_template and args_template[1] then refname = args_template[1] or refname end
	if refname ~= "" then
		reftxt = frame:preprocess('<ref name="' .. refname .. '" />')
	end
--	local reftxt = frame:preprocess('<ref name="' .. refname .. '" />')
	--
	local detail, detailtxt = "", ""
	if args_invoke and args_invoke[2] then detail = args_invoke[2] or detail end
	if args_template and args_template[2] then detail = args_template[2] or detail end
	if detail ~= "" then
		detailtxt = '<sup><span style="color:#0645ad;">' .. detail .. '</span></sup>'
	end
--	local detailtxt = '<sup><span style="color:#0645ad;">' .. detail .. '</span></sup>'
	return reftxt .. detailtxt
end

return p