This is the current revision of this page, as edited by imported>MSGJ at 11:57, 5 October 2023(simp?). The present address (URL) is a permanent link to this version.Revision as of 11:57, 5 October 2023 by imported>MSGJ(simp?)
This Lua module is used on approximately 109,000 pages. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them.
This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing.
This module allows wikitext to read values from data modules.
localmt={}functionmt.__index(t,k)returnfunction(frame)localsuccess,data=pcall(mw.loadData,k)ifnotsuccessthensuccess,data=pcall(mw.loadJsonData,k)ifnotsuccessthenerror("'"..k.."' is not a valid data page")endendfori,vinipairs(frame.args)dolocalty=type(data)ifty~='table'thenlocalargs={}forj=1,i-1doargs[j]=frame.args[j]endifframe.args.softfailthenreturn'<span class="error">[[Category:Pages with failed Module:Data lookups]]Error: Tried to read index "'..mw.text.nowiki(v)..'" of mw.loadData("'..mw.text.nowiki(k)..'").'..mw.text.nowiki(table.concat(args,'.'))..', which is a '..ty..'</span>'elseerror('Tried to read index "'..v..'" of mw.loadData("'..k..'").'..table.concat(args,'.')..', which is a '..ty)endendlocalnextdata=data[v]ifnextdata==nilandtonumber(v)thendata=data[tonumber(v)]elsedata=nextdataendendreturndataendendreturnsetmetatable({},mt)