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