Module:Infobox/Widget/List: Difference between revisions

From TwogPedia
No edit summary
Tag: Reverted
mNo edit summary
Tag: Manual revert
 
(One intermediate revision by the same user not shown)
Line 7: Line 7:
for i, v in ipairs(array) do
for i, v in ipairs(array) do
v = mw.text.trim(v)
v = mw.text.trim(v)
local pageExists = mw.getCurrentFrame():callParserFunction('#ifexist', v, 'yes', 'no' )
local div = mw.html.create('div')
local div = mw.html.create('div')
:wikitext('[[' .. v .. ']]')
if ( pageExists == 'yes' ) then
div:wikitext('[[' .. v .. '|' .. v .. ']]')
else
div:wikitext(v)
end
container:node(div)
container:node(div)
end
end
return container
return container
end
end


return List
return List

Latest revision as of 11:44, 29 September 2023

Documentation for this module may be created at Module:Infobox/Widget/List/doc

local List = {}

function List.make(arr)
	local container = mw.html.create('div')
	local array = mw.text.split(arr, ',')
	
	for i, v in ipairs(array) do
		v = mw.text.trim(v)
		local pageExists = mw.getCurrentFrame():callParserFunction('#ifexist', v, 'yes', 'no' )
		local div = mw.html.create('div')
		if ( pageExists == 'yes' ) then 
			div:wikitext('[[' .. v .. '|' .. v .. ']]')
		else 
			div:wikitext(v)
		end
		container:node(div)
	end

	return container
end


return List