stringx.apply_template works with $snake_case_symbols

This commit is contained in:
Max Cahill 2021-07-13 16:47:19 +10:00
parent 292345b953
commit 76ed4b1a02

View File

@ -214,7 +214,7 @@ stringx.dedent = stringx.deindent
--supports $template style values, given as a table or function
-- ie ("hello $name"):format({name = "tom"}) == "hello tom"
function stringx.apply_template(s, sub)
local r = s:gsub("%$(%w+)", sub)
local r = s:gsub("%$([%w_]+)", sub)
return r
end