Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:InfoboxBuilder/doc

From Sekaipedia
Revision as of 23:57, 5 August 2022 by ChaoticShadow (talk | contribs) (Created page with "{{documentation subpage}} {{Lua|Module:Navbar}} == Building an Infobox == === Import the module === <source lang="lua"> local InfoboxBuilder = require('Module:InfoboxBuilder') </source> === Unpack the frame arguments === <source lang="lua"> function p.main(frame) local args = frame:getParent().args ... </source> === Create the infobox object === <source lang="lua"> local infobox = InfoboxBuilder.new() </source> === Set the infobox name === Setting the infobox name...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is the documentation page for Module:InfoboxBuilder

Building an Infobox

Import the module

local InfoboxBuilder = require('Module:InfoboxBuilder')

Unpack the frame arguments

function p.main(frame)
	local args = frame:getParent().args
	...

Create the infobox object

local infobox = InfoboxBuilder.new()

Set the infobox name

Setting the infobox name sets the template that the infobox links to inside of the navbar.

infobox:setName('Infobox')

Define the parameters

When defining the parameters, the arguments will be processed and postprocessed when given a function or table. pFunc is an optional processing function or table that will transform the raw argument value into a specific format. dFunc is an optional postprocessing function or table that will transform the processed argument for display purposes. An optional default value for the raw argument can be set using the default option.

An example of using pFunc and dFunc would be to have pFunc be a function that splits a comma separated list into a table in Lua and have dFunc be a function that turns a table into an unordered list in HTML.

infobox:setParams {
	...
}

Pass in the arguments

infobox:setArgs(args)

Process the arguments

Processing the arguments will set default value (if it exists) and turn the raw argument passed in from setArgs(args) into a processed format for each parameter. This step is required or else the infobox will not work.

infobox:processArgs()

Specify a category map

A category map can be optionally set. This uses the processed (not postprocessed) argument and generates the correct categories.

infobox:setCategoryMap({
	...
})

Prepare

Create the look of the infobox by adding headers, images, or rows. If the values shown in these cells use the value from parameters, it will use the postprocessed value.

-- add a header or subheader
infobox:addHeader(
	{...},
	{...}
)

-- add an image
infobox:addImage(
	{...},
	{...}
)

-- add a row
infobox:addRow(
	{...},
	{...}
)

Build

To build the infobox from data into an HTML table, call the tostring() function.

infobox:tostring()

Get the categories from the category map

To get the categories, call the getCategories() function.

infobox:getCategories()

Functions

Cookies help us deliver our services. By using our services, you agree to our use of cookies.