Module:InputBadge

From BerserkerLoop
Jump to navigation Jump to search

Documentation for this module may be created at Module:InputBadge/doc

local p = {}

function p.drawInputBadge(frame)
  local wikitext = ""
  local numInputs = count(frame.args[1], '\\') + 1
  local index = 1
  for token in string.gmatch(frame.args[1], '([^\\]+)') do
    input = token

    wikitext = wikitext .. "<span class=\"input-badge\"><b\>" .. input .. "</b></span>"
  
    if index ~= numInputs then
      wikitext = wikitext .. " or "
    end

    index = index + 1
  end
  
  return wikitext
end

function count(base, pattern)
    return select(2, string.gsub(base, pattern, ""))
end

return p