Module:Collapsible: Difference between revisions

From Chalo Chatu, Zambia online encyclopedia
Created page with "local p = {} function p.collapsible(frame) -- Prefer your local Module:Collapsible list if it exists local ok, m = pcall(require, 'Module:Collapsible list') if ok and m and type(m.main) == 'function' then return m.main(frame) end -- Fallback to Module:Navbox if your setup routes collapsible lists via Navbox local ok2, nav = pcall(require, 'Module:Navbox') if ok2 and nav and type(nav.navbox) == 'function' then -- Pass through unchanged; may not render as a li..."
 
No edit summary
 
Line 2: Line 2:


function p.collapsible(frame)
function p.collapsible(frame)
-- Prefer your local Module:Collapsible list if it exists
-- Prefer Collapsible list → main
local ok, m = pcall(require, 'Module:Collapsible list')
local ok, mod = pcall(require, 'Module:Collapsible list')
if ok and m and type(m.main) == 'function' then
if ok and mod and type(mod.main) == 'function' then
return m.main(frame)
return mod.main(frame)
end
end


-- Fallback to Module:Navbox if your setup routes collapsible lists via Navbox
-- Optional fallback: Navbox → navbox (if present on your wiki)
local ok2, nav = pcall(require, 'Module:Navbox')
local ok2, nav = pcall(require, 'Module:Navbox')
if ok2 and nav and type(nav.navbox) == 'function' then
if ok2 and nav and type(nav.navbox) == 'function' then
-- Pass through unchanged; may not render as a list but avoids hard failure
return nav.navbox(frame)
return nav.navbox(frame)
end
end


-- Last resort: fail clearly
return 'Module error: expected Module:Collapsible list.main or Module:Navbox.navbox to handle "collapsible".'
return 'Module error: no handler available for "collapsible". Ensure Module:Collapsible list (with main) or Module:Navbox is installed.'
end
end


return p
return p