Module:InfoboxBuilder/doc
| This module is rated as alpha. It is ready for limited use and third-party feedback. It may be used on a small number of pages, but should be monitored closely. Suggestions for new features or adjustments to input and output are welcome. |
This module provides a builder-style interface to Module:Infobox, which allows you to dynamically construct infoboxes without having to wrangle row numbers. Currently this can only be used by other modules.
Overview
This module provides a single class named InfoboxBuilder, which you can create an instance of by calling .new().
local InfoboxBuilder = require('Module:InfoboxBuilder').InfoboxBuilder
-- later on in the module:
function p.someFunction( frame )
local builder = InfoboxBuilder.new()
end
| Above | |
|---|---|
| Below |
InfoboxBuilder has two basic features: firstly, it functions as an accumulator for arguments to Module:Infobox, e.g.
InfoboxBuilder.new()
:bodystyle("background-color: #FFD3D3")
:title("Title")
:above("Above")
:below("Below")
:build()
is the equivalent of
frame:expandTemplate{ title = 'Infobox', args = {
["bodystyle"] = "background-color: #FFD3D3",
["title"] = "Title",
["above"] = "Above",
["below"] = "Below"
}}
and secondly, it takes care of numbering your subheaders/images/rows for you, e.g.
| Subheader 1 | |
| Subheader 2 | |
![]() | |
![]() This image has a caption | |
| Header 1 | |
|---|---|
| Label | Data |
| Only Data | |
| Header 2 | |
| Fancy Row? | Yes |
InfoboxBuilder.new()
:title("Title")
:subheader("Subheader 1")
:subheader{
subheader = "Subheader 2",
subheaderstyle = "color: red"
}
:image("[[File:Example.jpg|upright=0.4]]")
:image{
image = "[[File:Example-serious.jpg|upright=0.4]]",
caption = "This image has a caption"
}
:header("Header 1")
:row("Data", "Label")
:row("Only Data")
:header{
header = "Header 2",
rowstyle = "background-color: #FF746C"
}
:row{
data = "Yes",
label = "Fancy Row?",
rowstyle = "background-color: #FFFFC5"
}
:build()
is the equivalent of
frame:expandTemplate{ title = 'Infobox', args = {
["title"] = "Title",
["subheader1"] = "Subheader 1",
["subheader2"] = "Subheader 2",
["subheaderstyle2"] = "color: red"
["image1"] = "[[File:Example.jpg|upright=0.4]]",
["image2"] = "[[File:Example-serious.jpg|upright=0.4]]",
["caption2"] = "This image has a caption",
["header1"] = "Header 1",
["label2"] = "Label",
["data2"] = "Data",
["data3"] = "Only Data",
["header4"] = "Header 2",
["rowstyle4"] = "background-color: #FF746C"
["label5"] = "Fancy Row?",
["data5"] = "Yes",
["rowstyle5"] = "background-color: #FFFFC5"
}}
Usage
The InfoboxBuilder class acts as an accumulator for parameters to Module:Infobox which will be passed along once you invoke the InfoboxBuilder:build() function. All non-repeated parameters (e.g., title, below, subheaderstyle) can be set by calling InfoboxBuilder:parameter(value) where parameter is the parameter name and value is the parameter value[a] (note that italic title should be passed along using InfoboxBuilder:italicTitle(value) as a special case since it contains a space. Similarly, all repeated parameters (e.g., header(n), label(n), etc.) can be set using the subheader, image, header, and row functions, each of which accept all parameters which should be linked together at the same time (these parameters can be passed as either positional arguments or named arguments, see below. All functions support chaining.
InfoboxBuilder:subheaderInfoboxBuilder:subheader(subheader, subheaderstyle, subheaderrowclass)InfoboxBuilder:subheader{ subheader = subheader, subheaderstyle = subheaderstyle, subheaderrowclass = subheaderrowclass }
InfoboxBuilder:imageInfoboxBuilder:image(image, caption, imagerowclass)InfoboxBuilder:image{ image = image, caption = caption, imagerowclass = imagerowclass }
InfoboxBuilder:headerInfoboxBuilder:header(header, rowclass, rowstyle)InfoboxBuilder:header{ header = header, rowclass = rowclass, rowstyle = rowstyle }
InfoboxBuilder:rowInfoboxBuilder:row(data, label, class, rowclass, rowstyle, rowcellstyle)InfoboxBuilder:row{ data = data, label = label, class = class, rowclass = rowclass, rowstyle = rowstyle, rowcellstyle = rowcellstyle }
- ^ This module supports all parameters supported by Module:Infobox.
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.

