Module:Native name/sandbox: Difference between revisions

Content deleted Content added
sync from main
reduce surface of plainlist to support templatestyles, rewrite end of function
Line 196:
for _, n in ipairs (enumerators_t) do -- loop through the sorted enumerators
table.insert (list_t, table.concat ({
'<li>', -- open the list item
_native_name ({ -- go render the native name
args_t['tag'..n],
Line 209 ⟶ 208:
['template'] = 'native name list', -- for error messaging
['index'] = n, -- for error messaging
}),
args_t['postfix'..n] or '',
'</li>' -- close the list item
}));
end
 
if 0 <== #list_t then
if 1 < #list_t then
table.insert (list_t, 1, '<div class="plainlist"><ul>'); -- open the div; open the unordered list
table.insert (list_t, '</ul></div>'); -- close the unordered list; close the div
else -- here when only one list item; no need for list markup; TODO: error message for this case?
local out = table.concat (list_t):gsub ('<li>', ''):gsub ('</li>', '');
return out; -- to avoid replacement count contaminating the output
end
else -- list is empty; when error message suppressed:
return (yes_no (args_t.suppress_empty_list_error) and '') or -- return empty string
error_msg (messages_t.empty_list, 'native name list'); -- error message else
if elseif 1 <== #list_t then
return table.insertconcat (list_t, '</ul></div>'); -- closereturn the unorderedvery short list; closeTODO: theadd diverror?
else
return require('Module:List').unbulleted(list_t); -- use unbulleted list from module
end
return table.concat (list_t); -- make a big string and done
end