Jump to content

Module:TestModule: Difference between revisions

From NewsWikiTestbed
AdamZachar (talk | contribs)
No edit summary
AdamZachar (talk | contribs)
No edit summary
Line 32: Line 32:
  end
  end


  for i, topic in ipairs(topics) do
  for i, error in ipairs(errors2) do
   output = output .. " <li>" .. "[[" .. topic.topicName .. "]]"
   output = output .. " <li>" .. "[[" .. error .. "]]"
  end
  end



Revision as of 11:22, 10 June 2025


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.getDbData {
   db = CaseData
   , query = childrenTopics
   , data = "topicName = topic_name"
   , parameters = parentTopic
  }


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

 for i, error in ipairs(errors2) do
  output = output .. " <li>" .. "[[" .. error .. "]]"
 end


 return output
end


return p