Módulo:Teste: diferenças entre revisões
Saltar para a navegação
Saltar para a pesquisa
Sem resumo de edição |
Sem resumo de edição |
||
| Linha 7: | Linha 7: | ||
function p.qualifiers(frame) | function p.qualifiers(frame) | ||
local entity = mw.wikibase.getEntity("Q4") | local entity = mw.wikibase.getEntity("Q4") | ||
local snak = entity['claims']['P26'][1]['qualifiers']['P9'] | |||
return mw.wikibase.entity:formatStatements("P26") | return mw.wikibase.entity:formatStatements("P26") | ||
end | |||
function p.entidade() | |||
local entity = "Q4"-- trim(frame.args[2]) | |||
if not entity:match('^[QP]%d{1,10}$') then | |||
entity = mw.wikibase.resolvePropertyId(entity) or entity | |||
end | |||
-- entity = mw.wikibase.getEntity(trim(frame.args[2]) or nil) | |||
if entity == '' then | |||
entity = mw.wikibase.getEntity() | |||
if entity == nil or entity.claims == nil then return 'No wikidata entity' end | |||
else | |||
entity = mw.wikibase.getEntity(entity) | |||
if entity == nil then | |||
return 'No wikidata entity: ' .. entity | |||
end | |||
end | |||
end | end | ||
return p | return p | ||
Revisão das 17h32min de 11 de maio de 2020
A documentação para este módulo pode ser criada na página Módulo:Teste/doc
local p = {}
function p.foo(frame)
return mw.wikibase.getLabel("P9")
end
function p.qualifiers(frame)
local entity = mw.wikibase.getEntity("Q4")
local snak = entity['claims']['P26'][1]['qualifiers']['P9']
return mw.wikibase.entity:formatStatements("P26")
end
function p.entidade()
local entity = "Q4"-- trim(frame.args[2])
if not entity:match('^[QP]%d{1,10}$') then
entity = mw.wikibase.resolvePropertyId(entity) or entity
end
-- entity = mw.wikibase.getEntity(trim(frame.args[2]) or nil)
if entity == '' then
entity = mw.wikibase.getEntity()
if entity == nil or entity.claims == nil then return 'No wikidata entity' end
else
entity = mw.wikibase.getEntity(entity)
if entity == nil then
return 'No wikidata entity: ' .. entity
end
end
end
return p