Module:EcoVersionData/doc: Difference between revisions

From Eco - English Wiki
[unchecked revision][checked revision]
Demian (talk | contribs)
Add documentation.
 
No edit summary
Tag: 2017 source edit
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Documentation ==
{{DataModule}}
{{Data file module}}


== Usage ==
== Usage ==
To use the '''ecoVersion''' string in wikitext, see [[Template:EcoVersion]].
For usage through Lua, see the example code below.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- Load data only once per page. (Do no use require())
-- Load data only once per page. (Do no use require())
local VersionData = mw.loadData("Module:EcoVersion")
local VersionData = mw.loadData("Module:EcoVersionData")


-- Assert that some data was received, otherwise throw an error.
-- Assert that some data was received, otherwise throw an error.
assert(VersionData.eco, "Failed to load data from Module:EcoVersion!")
assert(VersionData.eco, "Failed to load data from Module:EcoVersionData!")


-- You may then use data from this module in your script.
-- You may then use data from this module in your script.
local ecoVersionData = VersionData.eco["eco"]
local ecoVersionData = VersionData.eco["eco"]
</syntaxhighlight>
</syntaxhighlight>
<includeonly>[[Category:Eco data files]]</includeonly>

Latest revision as of 12:25, 25 June 2024

Usage[edit source]

To use the ecoVersion string in wikitext, see Template:EcoVersion.

For usage through Lua, see the example code below.

-- Load data only once per page. (Do no use require())
local VersionData = mw.loadData("Module:EcoVersionData")

-- Assert that some data was received, otherwise throw an error.
assert(VersionData.eco, "Failed to load data from Module:EcoVersionData!")

-- You may then use data from this module in your script.
local ecoVersionData = VersionData.eco["eco"]