Content added Content deleted
mNo edit summary |
(using new builder) |
||
Line 3: | Line 3: | ||
------------------------ |
------------------------ |
||
local getArgs = require('Module:Arguments').getArgs |
local getArgs = require('Module:Arguments').getArgs |
||
local builder = require('Module:InfoboxBuilder') |
local builder = require('Module:InfoboxBuilder new') |
||
local p = {} |
local p = {} |
||
⚫ | |||
local function formatImage(image_name) |
local function formatImage(image_name) |
||
Line 17: | Line 16: | ||
infobox:setName('Infobox item') |
infobox:setName('Infobox item') |
||
:setWidth("330px") |
|||
:setParams{ |
:setParams{ |
||
{ name = 'item name', default = mw.title.getCurrentTitle().text }, |
{ name = 'item name', default = mw.title.getCurrentTitle().text }, |
||
{ name = 'image', |
{ name = 'image', dFunc = formatImage }, |
||
{ name = 'japanese' }, |
{ name = 'japanese' }, |
||
{ name = 'romaji' }, |
{ name = 'romaji' }, |
||
Line 28: | Line 26: | ||
} |
} |
||
:setArgs(args) |
:setArgs(args) |
||
:processArgs() |
|||
infobox |
infobox |
||
Line 38: | Line 37: | ||
:addRow( |
:addRow( |
||
{ |
{ |
||
{ tag = 'th', content = 'Japanese' |
{ tag = 'th', content = 'Japanese' }, |
||
{ tag = 'argtd', content = 'japanese' |
{ tag = 'argtd', content = 'japanese' } |
||
} |
} |
||
) |
) |
||
:addRow( |
:addRow( |
||
{ |
{ |
||
{ tag = 'th', content = 'Romaji' |
{ tag = 'th', content = 'Romaji' }, |
||
{ tag = 'argtd', content = 'romaji' |
{ tag = 'argtd', content = 'romaji' } |
||
} |
} |
||
) |
) |
||
:addRow( |
:addRow( |
||
{ |
{ |
||
{ tag = 'th', content = 'English' |
{ tag = 'th', content = 'English' }, |
||
{ tag = 'argtd', content = 'english' |
{ tag = 'argtd', content = 'english' } |
||
}, |
}, |
||
{ hideIfEmpty = { 'english' } } |
{ hideIfEmpty = { 'english' } } |
||
Line 58: | Line 57: | ||
:addRow( |
:addRow( |
||
{ |
{ |
||
{ tag = 'argtd', content = 'description', |
{ tag = 'argtd', content = 'description', css = { ['text-align'] = 'center' } } |
||
css = { ['text-align'] = 'center' } |
|||
} |
|||
} |
} |
||
) |
) |
||
⚫ | |||
if mw.title.getCurrentTitle().namespace == 0 then |
if mw.title.getCurrentTitle().namespace == 0 then |
||
categories = "[[Category:Items]]" .. categories |
categories = "[[Category:Items]]" .. categories |
Revision as of 03:56, 25 January 2022
This module depends on the following other modules: |
To generate {{Infobox item}}, invoke using the main function.
--------------------------
-- Module for [[Template:Infobox item]]
------------------------
local getArgs = require('Module:Arguments').getArgs
local builder = require('Module:InfoboxBuilder new')
local p = {}
local function formatImage(image_name)
return string.format("[[File:%s|128px]]", image_name)
end
function p.main(frame)
local args = getArgs(frame)
local infobox = builder.new();
infobox:setName('Infobox item')
:setParams{
{ name = 'item name', default = mw.title.getCurrentTitle().text },
{ name = 'image', dFunc = formatImage },
{ name = 'japanese' },
{ name = 'romaji' },
{ name = 'english' },
{ name = 'description' },
{ name = 'date' }
}
:setArgs(args)
:processArgs()
infobox
:addHeader({ tag = 'argth', content = 'item name' })
:addImage(
{
{ tag = 'argtd', content = 'image' },
}
)
:addRow(
{
{ tag = 'th', content = 'Japanese' },
{ tag = 'argtd', content = 'japanese' }
}
)
:addRow(
{
{ tag = 'th', content = 'Romaji' },
{ tag = 'argtd', content = 'romaji' }
}
)
:addRow(
{
{ tag = 'th', content = 'English' },
{ tag = 'argtd', content = 'english' }
},
{ hideIfEmpty = { 'english' } }
)
:addHeader({ tag = 'th', content = 'Item Description' }, { subheader = true })
:addRow(
{
{ tag = 'argtd', content = 'description', css = { ['text-align'] = 'center' } }
}
)
local categories = ""
if mw.title.getCurrentTitle().namespace == 0 then
categories = "[[Category:Items]]" .. categories
end
return infobox:tostring() .. categories
end
return p