2 ms·
XHP templates in Hack wind up being really nice, letting you create composable XML tags, defining attribute types, etc. And they look a lot like JSX, except wit
by krapp 9y ago
XHP templates in Hack wind up being really nice, letting you create composable XML tags, defining attribute types, etc. And they look a lot like JSX, except with extending classes. I suppose that counts as an "internal DSL."
//<csrf-form>(...)</csrf-form>
class :csrf-form extends :x:element {
attribute :form;
use XHPHelpers;
protected function Render(): XHPRoot
{
$token=get_csrf_token();
return <form>
<input type="hidden" name="token" value={$token}/>
{$this->getChildren()}
</form>;
}
}
More boilerplate than Twig, but no string concatenation.