Module:InfoboxNeue

local p = {}

--- Wrap the HTML into an infobox section --- @param table data {title, subtitle, content) --- @param table options {col} --- @return string html function p.wrapSection( data, options )	if data == nil or data[ 'content' ] == nil then return '' end	if options == nil then options = {} end

local html = mw.html.create( 'div' ):addClass( 'infobox__section' ) if data[ 'title' ] then html:tag( 'div' ):addClass( 'infobox__sectionHeader' ) :tag( 'div' ) :addClass( 'infobox__sectionTitle' ) :wikitext( data[ 'title' ] ) :done if data[ 'subtitle' ] then html:tag( 'div' ) :addClass( 'infobox__sectionSubtitle' ) :wikitext( data[ 'subtitle' ] ) :done end html:done end html:tag( 'div' ) :addClass( 'infobox__sectionContent') :wikitext( data[ 'content' ] )

if options[ 'col' ] == true then html:addClass( 'infobox__grid--cols-' .. options[ 'col' ] ) end

return tostring( html ) end

--- Return the HTML of the infobox item component as string --- @param table data {label, data, desc) --- @param table options {row, spacebetween, colspan} --- @return string html function p.addItem( data, options )	if data == nil or data[ 'data' ] == nil then return '' end	if options == nil then options = {} end

local html = mw.html.create( 'div' ):addClass( 'infobox-item' ) if options[ 'row' ] == true then html:addClass( 'infobox__grid--row' ) end if options[ 'spacebetween' ] == true then html:addClass( 'infobox__grid--space-between' ) end if options[ 'colspan' ] == true then html:addClass( 'infobox__grid--col-span' .. options[ 'colspan' ] ) end local dataOrder = { 'label', 'data', 'desc' } for _, key in pairs( dataOrder ) do		if data[ key ] then html:tag( 'div' ) :addClass( 'infobox-item__' .. key ) :wikitext( data[ key ] ) :done end end mw.logObject( html )

return tostring( html ); end

--- Wrap the infobox HTML --- @param string innerHtml inner html of the infobox --- @return string html infobox html with templatestyles function p.wrapInfobox( innerHtml ) local html = mw.html.create( 'div' ) html :addClass( 'infobox' ) :addClass( 'floatright' ) :wikitext( innerHtml ) return tostring( html ) .. mw.getCurrentFrame:extensionTag{ name = 'templatestyles', args = { src = 'Module:InfoboxNeue/styles.css' } } end

return p