libs/core: Add Pythonic string formatting syntax
This commit is contained in:
parent
451eacf8da
commit
0647fadb0a
1 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
--
|
||||
|
|
Loading…
Reference in a new issue