مودول:ب.ص.م/بيانات

من ويكيپيديا

local localdata = {}

--local wikidata = require('Module:Wikidata/fr')
local frame = mw.getCurrentFrame()
local modulename =  frame.args.name
local parent = frame:getParent() or frame
local templatename = parent:getTitle() -- au cas où il soit différent du nom du module
local params = parent.args
localdata.wikidata = frame:getParent().args.wikidata or frame.args.wikidata
function localdata.getEntity( val ) 
	if type(val) == 'table' then
		return val
	end
	if val == '-' then
		return nil
	end
	if val == '' then
		val = nil
	end
	return mw.wikibase.getEntity(val)
end
-- fill-up global variable localdata using params
for i, j in pairs(params) do
	if j and mw.text.trim(j) ~= '' then -- empty parameters are ignored
		localdata[i] = j
	end
end
localdata.templatename = templatename
localdata.modulename = modulename

-- load wikidata item:
localdata.item = localdata.getEntity(localdata.wikidata)

return localdata