Module:GetRels: Difference between revisions
From Bodhicitta
((by SublimeText.Mediawiker)) |
((by SublimeText.Mediawiker)) |
||
| Line 3: | Line 3: | ||
function p.main(frame) | function p.main(frame) | ||
local pagename = mw.title.getCurrentTitle().text | |||
local pdata = mw.loadData('Module:GetData/relationships') | local pdata = mw.loadData('Module:GetData/relationships') | ||
local pargs = frame:getParent().args | local pargs = frame:getParent().args | ||
| Line 16: | Line 17: | ||
relatedString = relatedString .. '<div>[[' .. relatedTo .. ']]</div>' | relatedString = relatedString .. '<div>[[' .. relatedTo .. ']]</div>' | ||
end | end | ||
output = output .. '<tr><th>' .. data.Relationship .. '</th><td>' .. relatedString .. '</td></tr>' | output = output .. '<tr><th>' .. data.Relationship .. '</th><td>' .. data.wikipage .. ': ' .. relatedString .. '</td></tr>' | ||
end | end | ||
end | end | ||
Revision as of 12:57, 3 July 2024
Documentation for this module may be created at Module:GetRels/doc
local p = {}
function p.main(frame)
local pagename = mw.title.getCurrentTitle().text
local pdata = mw.loadData('Module:GetData/relationships')
local pargs = frame:getParent().args
if not pdata then
return 'No relationships!'
else
local output = '<h1>Relationships</h1><table class="smwtable-clean th-top-right th-nowrap border">'
if type(pdata) == "table" then
for _, data in ipairs( pdata ) do
local relatedString = ''
for relatedTo in string.gmatch(data.RelatedTo, "([^;]+)") do
relatedString = relatedString .. '<div>[[' .. relatedTo .. ']]</div>'
end
output = output .. '<tr><th>' .. data.Relationship .. '</th><td>' .. data.wikipage .. ': ' .. relatedString .. '</td></tr>'
end
end
output = output .. '</table>'
return output
end
end
return p