Module:ListGeneration: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
Line 38: Line 38:
-- @return string The formatted list as an HTML string or comma-separated text.
-- @return string The formatted list as an HTML string or comma-separated text.
function p.createList(input, options)
function p.createList(input, options)
     if not input or input == '' then
     if not input or (type(input) == 'string' and input == '') or (type(input) == 'table' and #input == 0) then
         return ''
         return ''
     end
     end
Line 49: Line 49:
     local itemHook = options.itemHook
     local itemHook = options.itemHook


     -- Split the input string into a table of items using the existing robust function
     -- If input is a string, split it. Otherwise, assume it's a pre-split table.
     local items = NormalizationText.splitMultiValueString(input)
    local items
     if type(input) == 'string' then
        items = NormalizationText.splitMultiValueString(input)
    else
        items = input
    end
 
     if #items == 0 then
     if #items == 0 then
         return ''
         return ''