Editing Module:Table Fish
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") | ||
--- Create a HTML table with details on fish type animals. | --- Create a HTML table with details on fish type animals. | ||
Line 8: | Line 7: | ||
-- @author User:Demian | -- @author User:Demian | ||
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\">" } | ||
-- Create the table header. | -- Create the table header. | ||
Line 22: | Line 19: | ||
-- Create the table rows. | -- Create the table rows. | ||
for _, animalName in ipairs(sortedNames) do | for _, animalName in ipairs(sortedNames) do | ||
if AnimalUtils.isFishAnimal(data) then | if AnimalUtils.isFishAnimal(data) then | ||
AnimalUtils.insertAnimalListDataRow(tbl, animalName, | AnimalUtils.insertAnimalListDataRow(tbl, animalName, animals[animalName]) | ||
end | end | ||
end | end |