Module:Synonyms
Jump to navigation
Jump to search
This module is used to obtain a list of all the pages that are synonym redirects to another page. This is used by templates that query for Cargo data on a particular subject (e.g. Template:Nomenclature, description templates, etc.) where the data may be stored under a synonym. This allows game-specific terms to be used for storing data, rather than having to update them whenever the series term changes (i.e. the referenced page is moved).
This module exports the following functions.get
get(page)
Returns
- A list of all redirects to
page
using Template:Synonym.
Examples
# | Input | Output | Result |
---|---|---|---|
1 | get("Big Key")
| {"Boss Key", "Boss Room Key", "Nightmare Key"}
|
local p = {}
local h = {}
local Util = {
cargo = {
query = require("Module:Util/cargo/query"),
},
tables = {
map = require("Module:Util/tables/map")
}
}
function p.get(page)
if page == "" or page == nil then
-- mw.loadData is used to make the query execute only once per page
return mw.loadData("Module:Synonyms/CurrentPage")
else
-- If the desired page is not the current page (e.g. template documentation examples)
return h.query(page)
end
end
function h.query(page)
local synonyms = Util.cargo.query("Synonyms", "_pageName", {
where = {
redirectTarget = page,
}
})
return Util.tables.map(synonyms, "_pageName")
end
return p