Module:HF: Difference between revisions

Content deleted Content added
Created page with "local HF = {} local language = mw.language.new('en') function HF.explode( sep, text ) local sep, fields = sep or "::", {} local pattern = string.format("([^%s]+)", sep) ..."
 
Cleanup 1
Line 1:
local HF = {}mw.InfoboxBuilderHF
local language = mw.language.new('en')
 
function HF.explode( sep, text )
local sep, fields = sep or "::", {}
local pattern = string.format("([^%s]+)", sep)
text:gsub(pattern, function(c) fields[#fields+1] = c end)
return fields
end
function HF.trim(s)
if type(s) == "string" then
Line 16 ⟶ 9:
end
end
 
function HF.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 HF.print_r( t, name, indent )
local cart -- a container
Line 110 ⟶ 87:
end
function HF.firstToUpper( str )
return (str:gsub("^%l", string.upper))
end
function HF.round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
 
function HF.parseIndexedFields( args )
local input = {}