// From https://docs.hhvm.com/hack/XHP/introduction (MIT licensed) use namespace Facebook\XHP\Core as x; use type Facebook\XHP\HTML\{XHPHTMLHelpers, a, form}; final xhp class a_post extends x\element { // ^ keyword // ^ keyword // ^ keyword use XHPHTMLHelpers; attribute string href @required; // ^ attribute attribute string target; // ^ keyword <<__Override>> protected async function renderAsync(): Awaitable { $id = $this->getID(); $anchor = {$this->getChildren()}; // ^ tag.delimiter // ^ tag $form = (
:href} target={$this->:target} class="postLink"> {$anchor}
); $anchor->setAttribute( 'onclick', 'document.getElementById("'.$id.'").submit(); return false;', ); $anchor->setAttribute('href', '#'); // ^ method return $form; } }