A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.mediawiki.org/wiki/Special:MyLanguage/Extension:Capiunto/Infobox below:

Extension:Capiunto/Infobox - MediaWiki

Capiunto provides flexible Infobox functionality for Scribunto.

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

local capiunto = require 'capiunto'
capiunto.create( {
	title = 'Title of the Infobox'
} )
:addRow( 'A label', 'some data' )
:addHeader( 'A header between the data rows' )
:addRow( 'Another label', 'more data' )

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.

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 capiunto.name are available on the global capiunto table; functions documented as capiunto:name are methods of an capiunto object (see capiunto.create).

capiunto.create( options )

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

Options for an Infobox title[edit] Options regarding text above the Infobox[edit] Options specific to images[edit] Options regarding text below the Infobox[edit] Options regarding data styling[edit]

infobox:getHtml()

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

Example:

local capiunto = require 'capiunto'
local infobx = capiunto.create( {
	-- ...
} )
local html = tostring( infobox:getHtml() )

infobox:addSubHeader( text )
infobox:addSubHeader( text, class )
infobox:addSubHeader( text, class, style )

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

infobox:addImage( image )
infobox:addImage( image, caption )
infobox:addImage( image, caption, class )

Adds an image (passed as wikitext like [[File:Foo.png]]) to the Infobox. Optionally a caption can be added after the image. Also a CSS class can be passed which will be added to the table row wrapping the image.

infobox:addRow( label, data )
infobox:addRow( label, data, class )
infobox:addRow( label, data, class, rowClass )

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

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

infobox:addHeader( header )
infobox:addHeader( header, class )

Adds a header row to the Infobox with the given text (header). Optionally a class which will apply to header can be added.

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

capiunto:addWikitext[edit]

infobox:addWikitext( text )

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

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

CapiuntoInfoboxRender[edit]

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.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4