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

local cargo = mw.ext.cargo

-- --
-- Entry point.
function main( args )
	-- Find the ident.
	local queryArgs = {
		format = 'template',
		namedArgs = 'yes',
		where = 'ident = \'' .. args.ident .. '\''
	}
	-- local identData = cargo.query( 'idents', 'ident', queryArgs )

	-- Not found.
	if false and #identData ~= 1 then
		local err = mw.html.create( 'span' )
		err:attr( 'class', 'error' )
		err:wikitext( 'Warning: ident [[' .. args.ident .. '|<code>' .. args.ident .. '</code>]] pending (reload page)' )
		err:wikitext( '[[Category:Pages with unresolved idents]]' )
		return tostring( err )
	end

	-- Found.
	local out = mw.html.create( 'dfn' )
	local identUri = mw.uri.canonicalUrl( args.ident )
	out
		:attr( 'itemprop', 'identifier' )
		:attr( 'title', 'This page\'s identifier' )
		:attr( 'class', 'plainlinks' )
		:wikitext( '[[' .. args.ident .. '|' .. identUri.hostPort .. identUri.path .. ']]' )
    return tostring( out )
end

return {
 main = function( frame ) return main( frame.args ) end;
}

-- Testing:
-- =p.main({args={ident='foo'}})