Ugrás a tartalomhoz

Modul:Wikidata/Formatters

A Wikipédiából, a szabad enciklopédiából

Wikidata/Formatters[mi ez?] • [dokumentáció: mutat, szerkeszt] • [tesztek: létrehozás]

local p = {}

function p.formatImage( value, options )
    local str = '[[Image:' .. value .. '|thumb'
    if options.legend then
        str = str .. '|' .. options.legend
    end
    return str .. ']]'
end

function p.formatExpandTemplate(value, options)
	local template
	if type(value) == "string" then
		template = value
	else
		local id = "Q" .. value["numeric-id"]
		template = mw.wikibase.label(id) or mw.wikibase.sitelink(id)
	end
	if not template then
		return nil
	end
	if not mw.title.new("Sablon:" .. template).exists then
		if not options["missing template category"] or options["missing template category"] == "" then
			return nil
		end
		return "[[Kategória:" .. options["missing template category"] .. "]]"
	end
	return mw.getCurrentFrame():expandTemplate{title = template}
end

return p