From: Steven Barth Date: Sun, 24 Aug 2008 16:35:06 +0000 (+0000) Subject: libs/core: Add Pythonic string formatting syntax X-Git-Tag: 0.8.0~309 X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=0647fadb0a48a34fbf5af1c15532d04dd7277fd0;p=project%2Fluci.git libs/core: Add Pythonic string formatting syntax --- diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua index d8fc666233..cc15d3aeb5 100644 --- a/libs/core/luasrc/util.lua +++ b/libs/core/luasrc/util.lua @@ -27,6 +27,20 @@ limitations under the License. --- LuCI utility functions. module("luci.util", package.seeall) +-- +-- Pythonic string formatting extension +-- +getmetatable("").__mod = function(a, b) + if not b then + return a + elseif type(b) == "table" then + return a:format(unpack(b)) + else + return a:format(b) + end +end + + -- -- Class helper routines --