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 14: | Linha 14: | ||
function p.entidade() | function p.entidade() | ||
local entity = | local entity = trim(frame.args[1]) | ||
if not entity:match('^[QP]%d{1,10}$') then | if not entity:match('^[QP]%d{1,10}$') then | ||
entity = mw.wikibase.resolvePropertyId(entity) or entity | entity = mw.wikibase.resolvePropertyId(entity) or entity | ||
| Linha 25: | Linha 25: | ||
entity = mw.wikibase.getEntity(entity) | entity = mw.wikibase.getEntity(entity) | ||
if entity == nil then | if entity == nil then | ||
return 'No wikidata entity: ' .. | return 'No wikidata entity: ' .. frame.args[1] | ||
end | end | ||
end | end | ||
Revisão das 17h34min 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 = trim(frame.args[1])
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: ' .. frame.args[1]
end
end
end
return p