Module:IslandTable: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local function getPagesInCategory(category) | local function getPagesInCategory(category) | ||
local category_handler = require('Module:Category_handler') | local category_handler = require('Module:Category_handler') | ||
| Line 11: | Line 10: | ||
end | end | ||
function p.render() | function p.render() | ||
local islands = getPagesInCategory('Islands') | local islands = getPagesInCategory('Islands') | ||
local cities = {} | local cities = {} | ||
| Line 20: | Line 17: | ||
end | end | ||
-- | -- Debugging: Output the lists of islands and cities | ||
local | local debug_output = 'Islands:\n' | ||
for _, | for _, island in ipairs(islands) do | ||
debug_output = debug_output .. island .. '\n' | |||
end | end | ||
debug_output = debug_output .. '\nCities:\n' | |||
for island, cityList in pairs(cities) do | |||
debug_output = debug_output .. island .. ': ' .. table.concat(cityList, ', ') .. '\n' | |||
for | |||
end | end | ||
return debug_output | |||
return | |||
end | end | ||
return p | return p | ||
Latest revision as of 14:16, 17 October 2025
Documentation for this module may be created at Module:IslandTable/doc
local p = {}
local function getPagesInCategory(category)
local category_handler = require('Module:Category_handler')
local pages = category_handler.main({
category = category,
list = 'pages'
})
return pages or {}
end
function p.render()
local islands = getPagesInCategory('Islands')
local cities = {}
for _, island in ipairs(islands) do
cities[island] = getPagesInCategory('Cities in ' .. island)
end
-- Debugging: Output the lists of islands and cities
local debug_output = 'Islands:\n'
for _, island in ipairs(islands) do
debug_output = debug_output .. island .. '\n'
end
debug_output = debug_output .. '\nCities:\n'
for island, cityList in pairs(cities) do
debug_output = debug_output .. island .. ': ' .. table.concat(cityList, ', ') .. '\n'
end
return debug_output
end
return p