Editing Module:Table Animals
From Eco - English Wiki
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local Utils = require("Module:Utils") | local Utils = require("Module:Utils") | ||
local AnimalUtils = require("Module: | local AnimalUtils = require("Module:UtilsAnimalLists") | ||
local | local HTMLUtils = require("Module:UtilsHTML") | ||
local function addFootnotes(t) | local function addFootnotes(t) | ||
Line 16: | Line 16: | ||
end | end | ||
function p.main() | function p.main() | ||
-- Import the data. | |||
local animals = require("Module:AnimalData").animals | |||
-- Sort animals by their name so the generated table will be pre-sorted on page load. | -- Sort animals by their name so the generated table will be pre-sorted on page load. | ||
local sortedNames = Utils.getSortedKeys( | local sortedNames = Utils.getSortedKeys(animals) | ||
-- Table to insert data into. | -- Table to insert data into. | ||
local tbl = { "<table class=\"wikitable sortable\">" } | local tbl = { "<table class=\"wikitable sortable\">" } | ||
Line 32: | Line 29: | ||
-- Create the table rows. | -- Create the table rows. | ||
for _, animalName in ipairs(sortedNames) do | for _, animalName in ipairs(sortedNames) do | ||
AnimalUtils.insertAnimalListDataRow(tbl, animalName, | AnimalUtils.insertAnimalListDataRow(tbl, animalName, animals[animalName]) | ||
end | end | ||