Module:Recipe

Revision as of 23:36, 28 June 2026 by Toster234 (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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