Changed 'vars' arg in lume.format() to be optional

This commit is contained in:
rxi 2014-03-03 20:36:42 +00:00
parent 778e7f9800
commit d1e6c0334b
2 changed files with 2 additions and 1 deletions

View File

@ -211,7 +211,7 @@ instead of whitespace.
lume.trim(" Hello ") -- Returns "Hello"
```
### lume.format(str, vars)
### lume.format(str [, vars])
Returns a formatted string. The values of keys in the table `vars` can be
inserted into the string by using the form `"{key}"` in `str`.
```lua

View File

@ -231,6 +231,7 @@ end
function lume.format(str, vars)
vars = vars or {}
local f = function(x) return tostring(vars[x] or "{" .. x .. "}") end
return (str:gsub("{(.-)}", f))
end