Module:Infobox/Widget/List: Difference between revisions

From TwogPedia
No edit summary
Tag: Reverted
mNo edit summary
Tag: Reverted
Line 1: Line 1:
local List = {}
local List = {}


function List.make(arr)
function List.make(arr, prefix)
local container = mw.html.create('div')
local container = mw.html.create('div')
local array = mw.text.split(arr, ',')
local array = mw.text.split(arr, ',')
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)
        if prefix ~= nil then v = prefix .. v end
local div = mw.html.create('div')
local div = mw.html.create('div')
:wikitext('[[' .. v .. ']]')
:wikitext('[[' .. v .. ']]')

Revision as of 12:15, 13 June 2023

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

local List = {}

function List.make(arr, prefix)
	local container = mw.html.create('div')
	local array = mw.text.split(arr, ',')
	
	for i, v in ipairs(array) do
		v = mw.text.trim(v)
        if prefix ~= nil then v = prefix .. v end
		local div = mw.html.create('div')
			:wikitext('[[' .. v .. ']]')
		container:node(div)
	end
	return container
end

return List