Module:Collapsible

From Chalo Chatu, Zambia online encyclopedia
Jump to navigationJump to search

This module is a small compatibility shim that exposes a function named collapsible. It forwards calls to an available renderer so that legacy templates using Script error: No such module "…". do not break.

Purpose

Some imported templates call:

    or Script error: The function "collapsible" does not exist.

    On Chalo Chatu the primary entrypoint is main in Module:Collapsible list. This shim looks for that first; if unavailable, it may fall back to a compatible function in Module:Navbox (if present). If neither exists, it returns a clear error message.

    Usage

    Prefer the direct entrypoint:

      Only use this shim for legacy code that cannot be edited:

        Parameters

        Identical to Module:Collapsible list’s main:

        title / header
        Heading text.
        collapsed
        yes / no. Adds class collapsed when yes.
        1..50
        Positional items.
        class, id, list_style, item_style
        Optional styling hooks passed through when supported.

        Behavior

        • If Module:Collapsible list with function main(frame) exists, all arguments are forwarded to it.
        • Else, if Module:Navbox with function navbox(frame) exists, arguments are forwarded as-is (output may differ).
        • Else, a readable Module error string is returned.

        Migration guidance

        Where possible, update templates to call:

          This reduces indirection and makes behavior explicit.

          Troubleshooting

          • If you still see "Script error: The function 'collapsible' does not exist", ensure this page (Module:Collapsible) is created and that Module:Collapsible list exists with a main function.
          • If output appears but styling looks plain, add CSS for .chalo-collapsible classes in MediaWiki:Common.css.

          See also


          local p = {}
          
          function p.collapsible(frame)
          	-- Prefer Collapsible list → main
          	local ok, mod = pcall(require, 'Module:Collapsible list')
          	if ok and mod and type(mod.main) == 'function' then
          		return mod.main(frame)
          	end
          
          	-- Optional fallback: Navbox → navbox (if present on your wiki)
          	local ok2, nav = pcall(require, 'Module:Navbox')
          	if ok2 and nav and type(nav.navbox) == 'function' then
          		return nav.navbox(frame)
          	end
          
          	return 'Module error: expected Module:Collapsible list.main or Module:Navbox.navbox to handle "collapsible".'
          end
          
          return p