Module:Wd: Difference between revisions

Content deleted Content added
Added methods propertyWithUnit, qualifierWithUnit and propertyWithQualifier
No edit summary
Line 58:
end
 
local function getValue(snak, withUnitappendUnit)
withUnitappendUnit = withUnitappendUnit or false
if snak.snaktype ~= 'value' then return nil end
Line 74:
-- strip + signs from front
local value = mw.ustring.gsub(snak.datavalue.value['amount'], "\+(.+)", "%1")
if withUnitappendUnit then
local unit = convertUnit(snak.datavalue.value['unit'])
if unit then
Line 86:
return unknownDatatypeError(snak.datavalue.type)
end
end
 
local function getValueWithUnit(snak)
return getValue(snak, true)
end
 
Line 259 ⟶ 255:
end
else
local value = getValue(v.mainsnak, withUnit)
if withUnit then
value = getValueWithUnit(v.mainsnak)
else
value = getValue(v.mainsnak)
end
if value then appendOutput(value, rankPos) end
end
Line 344 ⟶ 335:
end
else
local value = getValue(v2, withUnit)
if withUnit then
value = getValueWithUnit(v2)
else
value = getValue(v2)
end
if value then outQualifier = value end
end
Line 367 ⟶ 353:
end
else
local value = getValue(v.mainsnak, withUnit)
if withUnit then
value = getValueWithUnit(v.mainsnak)
else
value = getValue(v.mainsnak)
end
if value then outValue = outValue .. value end
end