Module:Collapsible box

--[=[ Implements Template:Collapsible box ]=]

local p = {} --p stands for package

local getArgs = require('Module:Arguments').getArgs local yesno = require('Module:Yesno') local make_attribute_string = require('Module:Optional CSS attribute').make_attribute_string

function p._collapsible_box(args) local title = args.title -- outer div -- classes local collapsed_class = "" if yesno(args.collapsed) or false then collapsed_class = "mw-collapsed" end local outer_div_class = make_attribute_string("class", {['class'] = "mw-collapsible " .. collapsed_class .. " " .. (args.class_outer or '')}) -- style local outer_div_padding = "0.5em" if title then outer_div_padding = "0" end local outer_div_style = make_attribute_string("style", {		margin = "0.5em auto",		padding = outer_div_padding .. " 0.5em 0.5em 0.5em",		style = args.style_outer	}) -- div local outer_div = ''	-- title -- force a so we can zero out the top margin local title_content = "" if title then title_content = "" .. title .. " "	end local title_p = '' .. title_content .. ' '	-- content local content_div_class = make_attribute_string("class", {class = "mw-collapsible-content " .. (args.class_content or '')}) local content_div_style = make_attribute_string("style", {style = args.style_content}) local content_div = ''	-- combined local closing_divs = '' if yesno(args.closing_div) or true then closing_divs = ' ' end local box = outer_div .. title_p .. content_div .. (args.content or '') .. closing_divs end

function p.collapsible_box(frame) return p._collapsible_box(getArgs(frame)) end

return p