Module:AutoHeader: Difference between revisions
Appearance
Intcreator (talk | contribs) No edit summary |
Intcreator (talk | contribs) No edit summary |
||
Line 4: | Line 4: | ||
-- local ret = mw.visualdata.query( schema ("inventory_item"), query (string), printouts (list or table), params (table) ) | -- local ret = mw.visualdata.query( schema ("inventory_item"), query (string), printouts (list or table), params (table) ) | ||
local ret = mw.visualdata.query( 'Phone', '[[manufacturer::+]]', {'manufacturer'}, {} ) | local ret = mw.visualdata.query( 'Phone', '[[manufacturer::+]]', {'manufacturer'}, {} ) | ||
return ret | |||
end | |||
p.getJsonString = function(frame) | |||
local data = p.getJson(frame) | |||
return mw.text.jsonEncode(ret) | return mw.text.jsonEncode(ret) | ||
end | end | ||
Line 9: | Line 14: | ||
p.getIntroParagraph = function(frame) | p.getIntroParagraph = function(frame) | ||
local data = p.getJson(frame) | local data = p.getJson(frame) | ||
local first = data.titlesfeg | -- local first = data.titlesfeg | ||
return first | -- return first | ||
local title = data[0].title | |||
local manufacturer = data[0].data.manufacturer | |||
return string.format("The %q was manufactured by %q", title, manufacturer) | |||
end | end | ||
return p | return p |
Revision as of 18:21, 6 January 2025
Documentation for this module may be created at Module:AutoHeader/doc
local p = {}
p.getJson = function(frame)
-- local ret = mw.visualdata.query( schema ("inventory_item"), query (string), printouts (list or table), params (table) )
local ret = mw.visualdata.query( 'Phone', '[[manufacturer::+]]', {'manufacturer'}, {} )
return ret
end
p.getJsonString = function(frame)
local data = p.getJson(frame)
return mw.text.jsonEncode(ret)
end
p.getIntroParagraph = function(frame)
local data = p.getJson(frame)
-- local first = data.titlesfeg
-- return first
local title = data[0].title
local manufacturer = data[0].data.manufacturer
return string.format("The %q was manufactured by %q", title, manufacturer)
end
return p