mirror of
https://github.com/don-philipe/knorke.git
synced 2025-11-08 14:57:02 +01:00
init files and helper added
This commit is contained in:
25
helpers.lua
Normal file
25
helpers.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
-- some things copied from vicious' helper
|
||||
|
||||
local rawget = rawget
|
||||
local helpers = {}
|
||||
|
||||
-- {{{ Loader for knorke modules
|
||||
function helpers.wrequire(table, key)
|
||||
local module = rawget(table, key)
|
||||
return module or require(table._NAME .. "." .. key)
|
||||
end
|
||||
-- }}}
|
||||
|
||||
-- {{ Format a string with args
|
||||
function helpers.format(format, args)
|
||||
for var, val in pairs(args) do
|
||||
format = format:gsub("$" .. (tonumber(var) and var or
|
||||
var:gsub("[-+?*]", function(i) return "%"..i end)),
|
||||
val)
|
||||
end
|
||||
|
||||
return format
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return helpers
|
||||
Reference in New Issue
Block a user