;
abstract protected function getDocs(): Vector<(string, string)>;
protected function getDescription(): ?string {
return null;
}
final protected function getTitle(): string {
return $this->getName().' - Hack Cookbook';
}
final protected function renderMainColumn(): :xhp {
$main_column =
{$this->getName()}
;
$description = $this->getDescription();
if ($description !== null) {
$main_column->appendChild(
{$description}
);
}
foreach ($this->getFilenames() as $filename) {
$file =
;
$main_column->appendChild($file);
}
$recipe = $this;
if ($recipe instanceof RecipeWithDemo) {
try {
$result = $recipe->getDemoResult();
} catch (Exception $e) {
$result = sprintf(
"Demo threw an %s:\n%s",
get_class($e),
$e->getMessage(),
);
}
$result = explode("\n", trim($result));
$result = array_map($x ==> {$x}
, $result);
$demo =
Demo
{$recipe->getDemoXHP()}
{$recipe->getDemoFilename()}
getDemoFilename()}/>
Output
{$result}
;
$main_column->appendChild($demo);
}
if (!$this->getDocs()->isEmpty()) {
$render_doc_link = function($doc) {
list($name, $link) = $doc;
$link = "http://hhvm.com/manual/en/$link.php";
return {$name};
};
$main_column->appendChild(
Relevant Official Documentation
{$this->getDocs()->map($render_doc_link)->toArray()}
);
}
return $main_column;
}
}