<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://cherry-pi.tailb1a250.ts.net/index.php?action=history&amp;feed=atom&amp;title=Module%3AInfoboxLua%2FComponents%2FSection</id>
	<title>Module:InfoboxLua/Components/Section - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://cherry-pi.tailb1a250.ts.net/index.php?action=history&amp;feed=atom&amp;title=Module%3AInfoboxLua%2FComponents%2FSection"/>
	<link rel="alternate" type="text/html" href="https://cherry-pi.tailb1a250.ts.net/index.php?title=Module:InfoboxLua/Components/Section&amp;action=history"/>
	<updated>2026-11-11T02:35:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.2</generator>
	<entry>
		<id>https://cherry-pi.tailb1a250.ts.net/index.php?title=Module:InfoboxLua/Components/Section&amp;diff=362&amp;oldid=prev</id>
		<title>Gravy: Created page with &quot;require( &#039;strict&#039; )  local tabber = mw.ext.tabber local util = require( &#039;Module:InfoboxLua/Util&#039; ) local types = require( &#039;Module:InfoboxLua/Types&#039; ) local itemComponent = require( &#039;Module:InfoboxLua/Components/Item&#039; ) local collapsibleComponent = require( &#039;Module:InfoboxLua/Components/Collapsible&#039; )  local p = {}  --- @param label string --- @return mw.html local function getLabelHtml( label ) 	local html = mw.html.create( &#039;div&#039; ) 	html:addClass( &#039;t-infobox-section-labe...&quot;</title>
		<link rel="alternate" type="text/html" href="https://cherry-pi.tailb1a250.ts.net/index.php?title=Module:InfoboxLua/Components/Section&amp;diff=362&amp;oldid=prev"/>
		<updated>2026-06-14T02:20:11Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;require( &amp;#039;strict&amp;#039; )  local tabber = mw.ext.tabber local util = require( &amp;#039;Module:InfoboxLua/Util&amp;#039; ) local types = require( &amp;#039;Module:InfoboxLua/Types&amp;#039; ) local itemComponent = require( &amp;#039;Module:InfoboxLua/Components/Item&amp;#039; ) local collapsibleComponent = require( &amp;#039;Module:InfoboxLua/Components/Collapsible&amp;#039; )  local p = {}  --- @param label string --- @return mw.html local function getLabelHtml( label ) 	local html = mw.html.create( &amp;#039;div&amp;#039; ) 	html:addClass( &amp;#039;t-infobox-section-labe...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require( &amp;#039;strict&amp;#039; )&lt;br /&gt;
&lt;br /&gt;
local tabber = mw.ext.tabber&lt;br /&gt;
local util = require( &amp;#039;Module:InfoboxLua/Util&amp;#039; )&lt;br /&gt;
local types = require( &amp;#039;Module:InfoboxLua/Types&amp;#039; )&lt;br /&gt;
local itemComponent = require( &amp;#039;Module:InfoboxLua/Components/Item&amp;#039; )&lt;br /&gt;
local collapsibleComponent = require( &amp;#039;Module:InfoboxLua/Components/Collapsible&amp;#039; )&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
--- @param label string&lt;br /&gt;
--- @return mw.html&lt;br /&gt;
local function getLabelHtml( label )&lt;br /&gt;
	local html = mw.html.create( &amp;#039;div&amp;#039; )&lt;br /&gt;
	html:addClass( &amp;#039;t-infobox-section-label&amp;#039; )&lt;br /&gt;
	html:wikitext( label )&lt;br /&gt;
	return html&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- @param section SectionComponentData&lt;br /&gt;
--- @return mw.html&lt;br /&gt;
local function getItemsHtml( section )&lt;br /&gt;
	local html = mw.html.create( &amp;#039;div&amp;#039; )&lt;br /&gt;
	html:addClass( &amp;#039;t-infobox-section-items&amp;#039; )&lt;br /&gt;
&lt;br /&gt;
	if section.columns and section.columns &amp;gt; 1 then&lt;br /&gt;
		html:css( &amp;#039;--infobox-section-columns&amp;#039;, tostring( section.columns ) )&lt;br /&gt;
		html:css( &amp;#039;--infobox-item-flex-direction&amp;#039;, &amp;#039;column&amp;#039; )&lt;br /&gt;
	else&lt;br /&gt;
		html:addClass( &amp;#039;t-infobox-section-items--single-col&amp;#039; )&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for _, itemData in ipairs( section.items ) do&lt;br /&gt;
		local itemHtml = itemComponent.getHtml( itemData )&lt;br /&gt;
		if itemHtml then&lt;br /&gt;
			html:node( itemHtml )&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return html&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- @param section SectionComponentData&lt;br /&gt;
--- @return mw.html|nil&lt;br /&gt;
local function getSubSectionsHtml( section )&lt;br /&gt;
	local tabberData = {}&lt;br /&gt;
&lt;br /&gt;
	for i, subSectionData in ipairs( section.sections ) do&lt;br /&gt;
		local label = subSectionData.label&lt;br /&gt;
		local contentHtml = p.getHtml( subSectionData, true )&lt;br /&gt;
&lt;br /&gt;
		if label and contentHtml then&lt;br /&gt;
			table.insert( tabberData, {&lt;br /&gt;
				label = label,&lt;br /&gt;
				content = tostring( contentHtml )&lt;br /&gt;
			} )&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if tabberData == {} then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local root = mw.html.create( &amp;#039;div&amp;#039; )&lt;br /&gt;
	root:addClass( &amp;#039;t-infobox-section-subsections&amp;#039; )&lt;br /&gt;
	root:node( tabber.render( tabberData ) )&lt;br /&gt;
&lt;br /&gt;
	return root&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- @param section SectionComponentData&lt;br /&gt;
--- @return mw.html|nil&lt;br /&gt;
local function getContentHtml( section )&lt;br /&gt;
	local html = mw.html.create()&lt;br /&gt;
	local isEmpty = true&lt;br /&gt;
&lt;br /&gt;
	if util.isNonEmptyString( section.content ) then&lt;br /&gt;
		isEmpty = false&lt;br /&gt;
		html:wikitext( section.content )&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if util.isNonEmptyTable( section.items ) then&lt;br /&gt;
		local itemsHtml = getItemsHtml( section )&lt;br /&gt;
		if itemsHtml then&lt;br /&gt;
			isEmpty = false&lt;br /&gt;
			html:node( itemsHtml )&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if util.isNonEmptyTable( section.sections ) then&lt;br /&gt;
		local subSectionsHtml = getSubSectionsHtml( section )&lt;br /&gt;
		if subSectionsHtml then&lt;br /&gt;
			isEmpty = false&lt;br /&gt;
			html:node( subSectionsHtml )&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return isEmpty and nil or html&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- @param class string|nil&lt;br /&gt;
--- @return string&lt;br /&gt;
local function getSectionClass( class )&lt;br /&gt;
	return &amp;#039;t-infobox-section&amp;#039; .. (util.isNonEmptyString( class ) and &amp;#039; &amp;#039; .. class or &amp;#039;&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- @param section SectionComponentData&lt;br /&gt;
--- @param contentHtml mw.html|nil&lt;br /&gt;
--- @param isSubSection boolean|nil&lt;br /&gt;
--- @return mw.html&lt;br /&gt;
local function getSimpleSectionHtml( section, contentHtml, isSubSection )&lt;br /&gt;
	local html = mw.html.create( &amp;#039;div&amp;#039; )&lt;br /&gt;
	html:addClass( getSectionClass( section.class ) )&lt;br /&gt;
&lt;br /&gt;
	if isSubSection ~= true and util.isNonEmptyString( section.label ) then&lt;br /&gt;
		html:node( getLabelHtml( section.label ) )&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	html:node( contentHtml )&lt;br /&gt;
&lt;br /&gt;
	return html&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- @param section SectionComponentData&lt;br /&gt;
--- @param contentHtml mw.html|nil&lt;br /&gt;
--- @return mw.html&lt;br /&gt;
local function getCollapsibleSectionHtml( section, contentHtml )&lt;br /&gt;
	return collapsibleComponent.getHtml( {&lt;br /&gt;
		summary = tostring( getLabelHtml( section.label ) ),&lt;br /&gt;
		content = tostring( contentHtml ),&lt;br /&gt;
		class = getSectionClass( section.class ),&lt;br /&gt;
		open = not section.collapsed&lt;br /&gt;
	} )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns the mw.html object of the infobox section component.&lt;br /&gt;
---&lt;br /&gt;
--- @param data table&lt;br /&gt;
--- @param isSubSection boolean|nil&lt;br /&gt;
--- @return mw.html|nil&lt;br /&gt;
function p.getHtml( data, isSubSection )&lt;br /&gt;
	--- @type SectionComponentData|nil&lt;br /&gt;
	local section = util.validateAndConstruct( data, types.SectionComponentDataSchema )&lt;br /&gt;
&lt;br /&gt;
	if not section then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local contentHtml = getContentHtml( section )&lt;br /&gt;
&lt;br /&gt;
	-- Subsection can&amp;#039;t be collapsible for now&lt;br /&gt;
	if section.collapsible == true and isSubSection ~= true then&lt;br /&gt;
		return getCollapsibleSectionHtml( section, contentHtml )&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return getSimpleSectionHtml( section, contentHtml, isSubSection )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Gravy</name></author>
	</entry>
</feed>