Module:Case: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
for _, part in pairs(parts) do | for _, part in pairs(parts) do | ||
title = title .. langObject:ucfirst(string.lower(part)) .. frame.args.split | title = title .. langObject:ucfirst(string.lower(part)) .. frame.args.split | ||
end | |||
if table.getn(pairs) > 1 then | |||
title = string.sub(title, 0, string.len(title) - 1) | |||
end | end | ||
return "[[" .. frame.args.link .. "|" .. title .. "]]" | return "[[" .. frame.args.link .. "|" .. title .. "]]" |
Revision as of 22:14, 22 May 2021
See usage on Lua error at line 11: bad argument #1 to 'getn' (table expected, got function)., Template:u, and template:l.
local p = {} --p stands for package
langObject = mw.getLanguage('simple')
function p.title_case(frame)
parts = mw.text.split(frame.args.link, frame.args.split, true)
title = ""
for _, part in pairs(parts) do
title = title .. langObject:ucfirst(string.lower(part)) .. frame.args.split
end
if table.getn(pairs) > 1 then
title = string.sub(title, 0, string.len(title) - 1)
end
return "[[" .. frame.args.link .. "|" .. title .. "]]"
end
function p.uppercase_first_letter(frame)
return "[[" .. frame.args.link .. "|" .. langObject:ucfirst(string.lower(frame.args.link)) .. "]]"
end
function p.lowercase(frame)
return "[[" .. frame.args.link .. "|" .. string.lower(frame.args.link) .. "]]"
end
return p