Content deleted Content added
→Call from within a module (_id): require( "Module:ResolveEntityId" )._id |
→Call from within a module (_id): Add notes Tag: Disambiguation links added |
||
Line 14:
{| class="wikitable"
|+ style="text-align:left"|
!Code !! Result !! Notes
|-
|<syntaxhighlight lang="lua">local resolveEntityId = require( "Module:ResolveEntityId" )._id
id = resolveEntityId('Q42')</syntaxhighlight>
|style="vertical-align: mid;"|<code>id</code> = <code>{{#invoke:ResolveEntityId|entityid|Q42|'''nil'''}}</code>
| "Q42" is a valid Wikidata ID, and a Wikidata items exists with that Id, so it is therefore returned intact
|-
|<syntaxhighlight lang="lua">local resolveEntityId = require( "Module:ResolveEntityId" )._id
id = resolveEntityId('Q0')</syntaxhighlight>
|style="vertical-align: mid;"|<code>id</code> = <code>{{#invoke:ResolveEntityId|entityid|Q0|'''nil'''}}</code>
| "Q0" is not a valid Wikidata ID, and while the Wikipedia article [[Q0]] exists, it is a disambiguation page, so <code>'''nil'''</code> is returned
|-
|<syntaxhighlight lang="lua">local resolveEntityId = require( "Module:ResolveEntityId" )._id
id = resolveEntityId('Q404')</syntaxhighlight>
|style="vertical-align: mid;"|<code>id</code> = <code>{{#invoke:ResolveEntityId|entityid|Q404|'''nil'''}}</code>
| "Q404" is a Wikidata redirect to Q395, so the latter is returned
|-
|<syntaxhighlight lang="lua">local resolveEntityId = require( "Module:ResolveEntityId" )._id
id = resolveEntityId('
|style="vertical-align: mid;"|<code>id</code> = <code>{{#invoke:ResolveEntityId|entityid|
| Q2147483647 is a valid Wikidata ID, but no entity exists with that ID, so <code>'''nil'''</code> is returned
|-
|<syntaxhighlight lang="lua">local resolveEntityId = require( "Module:ResolveEntityId" )._id
id = resolveEntityId('Douglas Adams')</syntaxhighlight>
|style="vertical-align: mid;"|<code>id</code> = <code>{{#invoke:ResolveEntityId|entityid|Douglas Adams|'''nil'''}}</code>
| The article [[Douglas Adams]] exists and has the Wikidata ID "Q42", so that is returned.
|-
|<syntaxhighlight lang="lua">local resolveEntityId = require( "Module:ResolveEntityId" )._id
id = resolveEntityId('ThisIsNotARealWikidataItem')</syntaxhighlight>
|style="vertical-align: mid;"|<code>id</code> = <code>{{#invoke:ResolveEntityId|entityid|ThisIsNotARealWikidataItem|'''nil'''}}</code>
| "ThisIsNotARealWikidataItem" is not a valid Wikidata ID, and no Wikipedia article exists at [[ThisIsNotARealWikidataItem]], so <code>'''nil'''</code> is returned
|-
|<syntaxhighlight lang="lua">local resolveEntityId = require( "Module:ResolveEntityId" )._id
id = resolveEntityId('ThisIsNotARealWikidataItem', 'Wikidata ID not found!')</syntaxhighlight>
|style="vertical-align: mid;"|<code>id</code> = <code>{{#invoke:ResolveEntityId|entityid|ThisIsNotARealWikidataItem|'Wikidata ID not found!'}}</code>
| Same as above, but the custom error message <code>Wikidata ID not found!</code> is returned
|-
|<syntaxhighlight lang="lua">local resolveEntityId = require( "Module:ResolveEntityId" )._id
id = resolveEntityId('WP:R')</syntaxhighlight>
|style="vertical-align: mid;"|<code>id</code> = <code>{{#invoke:ResolveEntityId|entityid|WP:R|'''nil'''}}</code>
| "WP:R" is not a valid Wikidata ID, and while [[WP:R]] exists, it is a redirect and does not have a Wikidata ID, so <code>'''nil'''</code> is returned
|}
|