Jump to content

Module:TestModule

From NewsWikiTestbed
Revision as of 10:49, 10 June 2025 by AdamZachar (talk | contribs)

local p = {} --p stands for package

function p.hello( frame )
 return "Hello, world!"
end

function p.externalDataTest( frame )
 local output = ""
 local targetShape = frame.args.targetShape
 local data, errors =
  mw.ext.externaldata.getWebData
  {
   url = 'https://discoursedb.org/wiki/Special:GetData/Fruits_data',
   data = {name = 'Name',  color = 'Color', shape = 'Shape'},
   format = 'CSV with header'
  }

 output = output .. "<ul>"
 for i, row in ipairs(data) do

  if row.shape == targetShape then
   output = output .. " <li>" .. "'''[[" .. row.shape .. "]]'''"
  else
   output = output .. " <li>" .. "[[" .. row.shape .. "]]"
  end

 end
 output = output .. "</ul>"

 return output
end

return p