Module:Recipe: Difference between revisions
Appearance
imported>JarlHiemas No edit summary |
Created page with "local p = {} local param = { station = 'station', sort = 'sort', sortDelim = ';', sortDelim2 = '¤', time = 'time', output = 'output', yield = 'yield', page = 'page' } local function addRecipe(name, amt) if not name or not amt then return "" end return '' .. name .. ' x ' .. amt end function p.main(frame) local args = require('Module:Arguments').getArgs(frame) local t = mw.html.create('table') :addClass('fandom-table article-table sort..." |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local param = { | local param = { | ||
station = 'station', | |||
sort = 'sort', | |||
sortDelim = ';', | |||
sortDelim2 = '¤', | |||
time = 'time', | |||
output = 'output', | |||
yield = 'yield', | |||
page = 'page' | |||
} | } | ||
function addRecipe( | local function addRecipe(name, amt) | ||
if not name or not amt then return "" end | |||
return '[[' .. name .. ']] x ' .. amt | |||
end | end | ||
function p.main(frame) | function p.main(frame) | ||
local args = require('Module:Arguments').getArgs(frame | local args = require('Module:Arguments').getArgs(frame) | ||
local t = mw.html.create('table') | |||
:addClass('fandom-table article-table sortable alternating-colors-table') | |||
local inputText = "" | |||
for k, v in pairs(args) do | |||
local isReserved = false | |||
for _, key in pairs(param) do | |||
if k == key then | |||
isReserved = true | |||
break | |||
end | end | ||
end | |||
if not isReserved then | |||
inputText = inputText .. addRecipe(k, v) .. "<br/>" | |||
end | end | ||
end | |||
t:tag('tr') | |||
:tag('td'):wikitext(inputText ~= "" and inputText or "-") | |||
t:tag('tr'):tag('td'):wikitext(args.station and ('[[' .. args.station .. ']]') or "-") | |||
t:tag('tr'):tag('td'):wikitext(args.time or "-") | |||
t:tag('tr'):tag('td'):wikitext(args.output and ('[[' .. args.output .. ']] x ' .. (args.yield or 1)) or "-") | |||
return t | |||
end | end | ||
return p | return p | ||
Latest revision as of 23:36, 28 June 2026
Documentation for this module may be created at Module:Recipe/doc
local p = {}
local param = {
station = 'station',
sort = 'sort',
sortDelim = ';',
sortDelim2 = '¤',
time = 'time',
output = 'output',
yield = 'yield',
page = 'page'
}
local function addRecipe(name, amt)
if not name or not amt then return "" end
return '[[' .. name .. ']] x ' .. amt
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame)
local t = mw.html.create('table')
:addClass('fandom-table article-table sortable alternating-colors-table')
local inputText = ""
for k, v in pairs(args) do
local isReserved = false
for _, key in pairs(param) do
if k == key then
isReserved = true
break
end
end
if not isReserved then
inputText = inputText .. addRecipe(k, v) .. "<br/>"
end
end
t:tag('tr')
:tag('td'):wikitext(inputText ~= "" and inputText or "-")
t:tag('tr'):tag('td'):wikitext(args.station and ('[[' .. args.station .. ']]') or "-")
t:tag('tr'):tag('td'):wikitext(args.time or "-")
t:tag('tr'):tag('td'):wikitext(args.output and ('[[' .. args.output .. ']] x ' .. (args.yield or 1)) or "-")
return t
end
return p