Module:TestModule

Revision as of 11:40, 10 June 2025 by AdamZachar (talk | contribs)

local p = {} --p stands for package

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

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

end

function p.externalDataTest( frame )
 local output = ""
 local parentTopic = frame.args.parentTopic

 local fruits, errors1 = mw.ext.externaldata.getWebData {
    url = "https://discoursedb.org/wiki/Special:GetData/Fruits_data"
  , data = "name=Name,color=Color,shape=Shape"
  , format = "CSV with header"
 }

 local topics, errors2 = mw.ext.externaldata.getExternalData {
   source = "CaseData"
   , query = "childrenTopics"
   , data = "topicName=topic_name"
   , parameters = parentTopic
  }

 output = output .. "<ul>"
 for i, fruit in ipairs(fruits) do
  output = output .. " <li>" .. "[[" .. fruit.shape .. "]]"
 end
 output = output .. "</ul>"

 output = output .. "<ul>"
 for i, topic in ipairs(topics) do
  output = output .. " <li>" .. "[[" .. topic.topicName .. "]]"
  local childTopics, errors3 = mw.ext.externaldata.getExternalData {
   source = "CaseData"
   , query = "childrenTopics"
   , data = "topicName=topic_name"
   , parameters = topic.topicName
  }
  for i, childTopic in ipairs(childTopics) do
   output = output .. " <li>" .. "[[" .. childTopic.topicName .. "]]"
  end
 end
 output = output .. "</ul>"


 return output
end


return p