vicious-widgets.vicious/helpers.lua
Adrian C. (anrxc) 4c74de711f Padding removed, along with deprecated helper functions.
If you have any use for it then continue using an older vicious tag,
or keep maintaining it in your local vicious copy.
2009-08-05 21:50:41 +02:00

42 lines
930 B
Lua

----------------------------------------------------------
-- Licensed under the GNU General Public License version 2
-- * Copyright (C) 2009 Adrian C. <anrxc_sysphere_org>
----------------------------------------------------------
-- {{{ Grab environment
local pairs = pairs
local string = { gsub = string.gsub }
-- }}}
-- Helpers: provides helper functions for vicious widgets
module("vicious.helpers")
-- {{{ Helper functions
-- {{{ Format a string with args
function format(format, args)
-- Format a string
for var, val in pairs(args) do
format = string.gsub(format, "$" .. var, val)
end
return format
end
-- }}}
--{{{ Escape a string
function escape(text)
local xml_entities = {
["\""] = "&quot;",
["&"] = "&amp;",
["'"] = "&apos;",
["<"] = "&lt;",
[">"] = "&gt;"
}
return text and text:gsub("[\"&'<>]", xml_entities)
end
-- }}}
-- }}}