Files
xamxam/app/templates/partials/form/form-help-block.php

25 lines
678 B
PHP

<?php
/**
* Renders a single form help block as HTML.
*
* Variables consumed:
* string $helpContent — raw Markdown string from the DB (may be empty).
* string $helpKey — block key, used as element id.
*
* Outputs nothing when $helpContent is empty or whitespace-only.
*/
$helpContent = trim($helpContent ?? '');
if ($helpContent === '') {
return;
}
$converter = new League\CommonMark\CommonMarkConverter(['html_input' => 'strip']);
$html = $converter->convert($helpContent)->getContent();
?>
<div class="student-help-block" id="help-<?= htmlspecialchars($helpKey ?? 'unknown') ?>">
<?= $html ?>
</div>
<?php
unset($helpContent, $converter, $html);