Module:Sandbox/shreyasminocha/Wikidata explained

local p = -- p stands for package

function p.prop(frame) local entityId = frame.args.entityId local propertyId = frame.args.propertyId local data = mw.wikibase.getBestStatements(entityId, propertyId) local out = for key, val in pairs(data) do local id = val.mainsnak.datavalue.value.id local label = mw.wikibase.getLabel(id) local sitelink = mw.wikibase.getSitelink(id) local sitelinkNoDisamb = sitelink local sitelinkDisambParen = string.find(sitelink or label, '%(') if sitelinkDisambParen ~= nil then sitelinkNoDisamb = string.sub(sitelink or label, 1, sitelinkDisambParen - 1 - 1) end if sitelink

nil then table.insert(out, label) else table.insert(out, "" .. sitelinkNoDisamb .. "") end end return table.concat(out, "
")end

return p