Module:Ident

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 #identData ~= 1 then local err = mw.html.create( 'span' ) err:attr( 'class', 'error' ) err:wikitext( 'Warning: ident &lsquo;' .. args.ident .. '&rsquo; pending' ) return tostring( err ) end

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

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

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