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 ) mw.logObject(#identData)

-- 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' ) out :attr( 'itemprop', 'identifier' ) :attr( 'title', 'This page\'s identifier' ) :wikitext( '[' .. mw.site.server .. '/' .. identData[1].ident .. ' ' .. identData[1].ident .. ']' ) return tostring( out ) end

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

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