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

local ShipInfobox = {}

-- This avoids using the {{#if:{{{factionreq|}}}||}} ParserFunction.
local function isempty(s)
  local result = false
  if type(s) == "nil" then
    result = true
  elseif type(s) == "string" then
    if s == "" then
      result = true
    end
  elseif type(s) == "table" then
    if next(s) == nil then
      result = true
    end
  end
  return result
end

function ShipInfobox.Factionreq( field )
    local text = 'Requires '.. field.Requirement ..' rank of '.. file.Rank ..' or higher'
    if not isempty(field.Requirement) then
        local output = mw.html.create('span')
        :addClass('factionreq'):wikitext(text)
        return tostring(output)
    end
end  

return ShipInfobox