Module:Util

-- 	Additional functions that are common to other modules. Although they could	be called into templates the overhead call into lua would generally greater	than using a built in mediawiki parser function where one exists.	When calling in to another module, use 'local util = require( "Module:Util")'	This will ensure consistency between modules.

local util = {}

-- return pagename without any disambiguation title function util.corename(frame) local result = mw.ustring.gsub(mw.title.getCurrentTitle.subpageText, '%s%(.*', '')   return result end

-- Added this function in as a common method to check if a variable is 	populated. Old code was making this check multiple times in different forms.	The child parameter is to check if a row exists when object is a table. function util.exists(object, child) if object ~= nil and object ~= '' then if child ~= nil then if object[child] ~= nil and object[child] ~= '' then return true else return false end else return true end else return false end end

--Trim function from http://lua-users.org/wiki/StringTrim function util.trim(s) return s:match'^%s*$' and '' or s:match'^%s*(.*%S)' end

return util