Defining this function locally so that it can be reworked in Module:Util.
Нет описания правки |
(Defining this function locally so that it can be reworked in Module:Util.) |
||
local h = {}
h.string = {}
function h.string.format(str, vars)
--[[
Allow string replacement using named arguments.
TODO:
* Support %d ?
* Support 0.2f ?
Parameters
----------
str : String to replace.
vars : Table of arguments.
Examples
--------
= h.string.format('{foo} is {bar}.', {foo='Dinner', bar='nice'})
References
----------
http://lua-users.org/wiki/StringInterpolation
]]
if not vars then
vars = str
str = vars[1]
end
return (string.gsub(str, "({([^}]+)})",
function(whole, i)
return vars[i] or whole
end))
end
-- Lazy loading for Module:Item link
local level_number = string.match(
stat_text:lower(),
i18n.item_table.granted_skills_level_pattern,
{
-- then add it to the cell:
if level_number then
level =
i18n.item_table.granted_skills_level_format,
{
-- not:
if v['items2.class'] == nil then
tbl[#tbl+1] =
i18n.item_table.granted_skills_skill_output_format,
{
il_args.html = v['items2.html']
end
tbl[#tbl+1] =
i18n.item_table.granted_skills_gem_output_format,
{
|