-
Notifications
You must be signed in to change notification settings - Fork 0
comment blocks
Alex Oliver edited this page May 21, 2026
·
1 revision
Brace uses standard HTML comment syntax for comment blocks. By default, comments are stripped from the rendered output.
Anything between <!-- and --> on a single line is removed.
<!-- This comment will not appear in the output -->
<p>Hello {{ name }}</p>Output:
<p>Hello Alice</p>A comment that spans several lines is also stripped entirely.
<!--
This is a multi-line comment.
It can span as many lines as needed.
Variables like {{ name }} are not processed here.
-->
<p>Visible content</p>Output:
<p>Visible content</p>Set remove_comment_blocks to false on the parser instance to preserve all HTML comments.
<?php
use Brace\Parser;
$brace = new Parser();
$brace->remove_comment_blocks = false;
echo $brace->parseInputString(
"<!-- still here -->\n<p>Hello</p>",
[],
false
)->return();
// Output:
// <!-- still here -->
// <p>Hello</p>Note: When
remove_comment_blocksisfalse, comments are preserved literally — any{{ variables }}inside them are still not processed.