Extension:Capiunto/Infobox

Capiunto provides flexible Infobox functionality for Scribunto.

With Capiunto Lua code to create a basic Infobox might look like this:

After creating an Infobox using the create method, content can be added in the order it will appear on the page using the various add* functions explained below. Calls

To convert the Infobox metatable to html either call infobox:getHtml (which will return a mw.html instance with the infobox) or Lua's tostring can be used. Also just returning the Infobox metatable is ok as Scribunto will automatically convert it to a string in order to display it on the wiki page.

Functions documented as  are available on the global   table; functions documented as   are methods of an capiunto object (see  ).

capiunto.create
Creates a new Infobox object, with the given. Supported  are:


 * : If set the Infobox will be made embeddable into another Infobox (it eg. wont have an own border).
 * : If set the Infobox will also be made embeddable into another Infobox, but preserve an own border.

Options for an Infobox title

 * : Text to put in the caption above the table (or as as section header before the whole content of this table, if this is a child Infobox marked with ).
 * : This parameter is inserted into the class attribute for the Infobox's  caption.
 * : Applies only to the  caption. Adding a background color is usually inadvisable since the text is rendered "outside" the Infobox.

Options regarding text above the Infobox

 * : Text to put within the topmost cell of the table (default font size is 125%).
 * : This parameter is inserted into the class attribute for the Infobox's  cell.
 * : Applies only to the  cell at the top of the Infobox. The default style has font-size:125%; since this cell is usually used for a title.

Options specific to images

 * : Style which applies to the text of image captions.
 * : Applies to the cells the images are in. This includes the text of the image caption, but for captions, you should set properties instead with  instead
 * : This parameter is inserted into the class attribute of all cells wrapping images.

Options regarding text below the Infobox

 * : Text to placed in the bottom cell, this could be used for footnotes, see-also, and other such information.
 * : This parameter is inserted into the class attribute for the Infobox's  cell.
 * : Applies only to the  cell at the bottom of the Infobox.

Options regarding data styling

 * : This parameter is inserted into the class attribute for the Infobox as a whole.
 * : Applies to the Infobox table as a whole.
 * : Applies to all header cells.
 * : Applies to all label cells.
 * : Applies to all data cells.

capiunto:getHtml
Returns a mw.html object holding the html the Infobox consists of. This can easily be converted into a string using tostring.

Example:

capiunto:addSubHeader
Adds a subheader, which will show at the top of the infobox, below the title and top text, with the given  to the Infobox. Optionally it's possible to pass raw CSS in the  parameter and a CSS class in the   one.

capiunto:addImage
Adds an  (passed as wikitext like  ) to the Infobox. Optionally a  can be added after the image. Also a CSS  can be passed which will be added to the table row wrapping the image.

capiunto:addRow
Adds a data row to the Infobox with the given  (can also be left empty) and. Optionally a  which will apply to the whole table row and a   which will only apply to data can be added.

Please note that the rows added with this function,  and   will be rendered in the order they have been added to the Infobox.

capiunto:addHeader
Adds a header row to the Infobox with the given text. Optionally a  which will apply to header can be added.

Please note that the rows added with this function,  and   will be rendered in the order they have been added to the Infobox.

capiunto:addWikitext
Adds arbitrary wikitext to the Infobox. This can eg. be a child  instance which has been casted to string by using Lua's.

Please note that the rows added with this function,  and   will be rendered in the order they have been added to the Infobox.

CapiuntoInfoboxRender
CapiuntoInfoboxRender is a module internally used for the rendering the Infobox. It is not supposed to be used outside of Capiunto as its interfaces can change at any time.