Geen bewerkingssamenvatting
Geen bewerkingssamenvatting
Regel 19: Regel 19:
if template == nil then return "" end
if template == nil then return "" end
local param = frame.args.param or ""
local param = frame.args.param or ""
for k,v in pairs( slotData ) do
--mw.log( k )
end


local res = ""
local res = ""
Regel 28: Regel 24:
local tree = slotData[template]
local tree = slotData[template]
if type(tree) == "table" then
if type(tree) == "table" then
for k,v in pairs( tree ) do
--for k,v in pairs( tree ) do
mw.log( "tree key: " .. k )
--mw.log( "tree key: " .. k )
end
--end
if tree[1][param] ~= nil then
if tree[1] ~= nil and tree[1][param] ~= nil then
res = tree[1][param]["_text"]
res = tree[1][param]["_text"]
end
end
end
end
else
else
--
-- do JSON, too?
end
end
 
return "not ready " .. res
return res
end
end


return p
return p

Versie van 4 sep 2025 09:09

Documentatie voor deze module kan aangemaakt worden op de volgende pagina: Module:Slot/doc

local p = {}

--[[
{{#invoke:Slot|getParamValue
|slot= // defaults to main
|page= // defaults to FULLPAGENAME
|template=
|param=Category
}}
]]--
p.getParamValue = function ( frame )
	local slot = frame.args.slot or "main"
	local page = frame.args.page or ""
	if page == "" then page = mw.title.getCurrentTitle().fullText end
    local slotData = {}
    slotData = mw.slots.slotData(slot,page)
    if slotData == {} then mw.log( "No slot data found" ) end
	local template = frame.args.template or nil
	if template == nil then return "" end
	local param = frame.args.param or ""

	local res = ""
	if template ~= nil then
		local tree = slotData[template]
		if type(tree) == "table" then
			--for k,v in pairs( tree ) do
				--mw.log( "tree key: " .. k )
			--end
			if tree[1] ~= nil and tree[1][param] ~= nil then
				res = tree[1][param]["_text"]
			end
		end
	else
		-- do JSON, too?
	end

	return res
end

return p