More actions
No edit summary |
Arvid Varg (talk | contribs) No edit summary |
||
| Line 18: | Line 18: | ||
function p.stripHouse(frame) | function p.stripHouse(frame) | ||
local name = mw.title.getCurrentTitle().text | local name = mw.title.getCurrentTitle().text | ||
local | local prefixes = { "House", "Clan", "Family", "Dynasty" } | ||
return | |||
for _, prefix in ipairs(prefixes) do | |||
local pattern = "^" .. mw.ustring.lower(prefix) .. "%s+" | |||
name = mw.ustring.gsub(name, "^" .. prefix .. "%s+", "") | |||
name = mw.ustring.gsub(name, "^" .. mw.ustring.lower(prefix) .. "%s+", "") | |||
name = mw.ustring.gsub(name, "^" .. mw.ustring.upper(prefix) .. "%s+", "") | |||
end | |||
return name | |||
end | end | ||
return p | return p | ||
Revision as of 21:05, 30 March 2026
Titles
! colspan="2" class="infobox-subheader" | Not on a character |-
! colspan="2" class="infobox-subheader" |
|-
| Gnoblin | |
|---|---|
| Using the template | |
| Gnoblin | |
|---|---|
| Simple name only | |
local p = {}
function p.processTitle(frame)
local input = frame.args[1] or ""
-- Check if input already looks like a {{Title}} template
if mw.ustring.match(input, "^%s*%{%{%s*[Tt]itle%s*[|}]") then
return input
end
-- Otherwise, expand the template properly
return frame:expandTemplate{
title = "Title",
args = { name = input }
}
end
function p.stripHouse(frame)
local name = mw.title.getCurrentTitle().text
local prefixes = { "House", "Clan", "Family", "Dynasty" }
for _, prefix in ipairs(prefixes) do
local pattern = "^" .. mw.ustring.lower(prefix) .. "%s+"
name = mw.ustring.gsub(name, "^" .. prefix .. "%s+", "")
name = mw.ustring.gsub(name, "^" .. mw.ustring.lower(prefix) .. "%s+", "")
name = mw.ustring.gsub(name, "^" .. mw.ustring.upper(prefix) .. "%s+", "")
end
return name
end
return p