Difference between revisions of "Module:Uses Wikidata"

From Shipbucket Wiki
Jump to: navigation, search
m (Changed protection level of Module:Uses Wikidata: less than 150 transclusions, and all on template documentation. semi should be good enough ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)))
 
(Trim any leading or trailing spaces from unnamed parameters passed by Template:Uses Wikidata that would prevent template/module from working as expected. Tested with template & module /sandbox and Template:Uses Wikidata/testcases.)
Line 6: Line 6:
 
local ii = 1
 
local ii = 1
 
while true do
 
while true do
local p_num = parent.args[ii] or ''
+
local p_num = mw.text.trim(parent.args[ii] or '')
 
if p_num ~= '' then
 
if p_num ~= '' then
 
local label = mw.wikibase.label(p_num) or "NO LABEL"
 
local label = mw.wikibase.label(p_num) or "NO LABEL"
result = result .. "<li><b><i>[[d:Property:" .. p_num .. "|" .. label .. " <small>(" .. string.upper(p_num) .. ")</small>]]</i></b> (see [[d:Special:WhatLinksHere/Property:" .. p_num .. "|uses]])</li>"
+
result = result .. "<li><b><i>[[d:Property:" .. p_num .. "|" .. label .. " <small>(" .. string.upper(p_num) .. ")</small>]]</i></b> (see [[d:Property talk:" .. p_num .. "|talk]]; [[d:Special:WhatLinksHere/Property:" .. p_num .. "|uses]])</li>"
 
ii = ii + 1
 
ii = ii + 1
 
else break
 
else break

Revision as of 01:20, 23 April 2017

Documentation for this module may be created at Module:Uses Wikidata/doc

local p = {}

function p.usesProperty(frame)
	local parent = frame.getParent(frame)
	local result = ''
	local ii = 1
	while true do
		local p_num = mw.text.trim(parent.args[ii] or '')
		if p_num ~= '' then
			local label = mw.wikibase.label(p_num) or "NO LABEL"
			result = result .. "<li><b><i>[[d:Property:" .. p_num .. "|" .. label .. " <small>(" .. string.upper(p_num) .. ")</small>]]</i></b> (see [[d:Property talk:" .. p_num .. "|talk]]; [[d:Special:WhatLinksHere/Property:" .. p_num .. "|uses]])</li>"
			ii = ii + 1
		else break
		end
	end
	return result
end
 
return p