From d1e6c0334b898a2cd46eafff93c28bbc9e44d9a3 Mon Sep 17 00:00:00 2001 From: rxi Date: Mon, 3 Mar 2014 20:36:42 +0000 Subject: [PATCH] Changed 'vars' arg in lume.format() to be optional --- README.md | 2 +- lume.lua | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3640de1..3b8c06f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lume.lua b/lume.lua index 2160f97..ce6aca5 100644 --- a/lume.lua +++ b/lume.lua @@ -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