public function RemoveHtmlComments::removeHtmlCommentsAsRenderArray in Twig - Remove HTML comments 8
Removes HTML comments from string.
Example: A string which has value <!--Start DEBUG--> ABCD <!--End DEBUG--> will be returned the output ABCD after using the the following function.
Parameters
string|null $string: A string or NULL.
Return value
array The string as markup render array without HTML comments.
File
- src/
TwigExtension/ RemoveHtmlComments.php, line 58
Class
- RemoveHtmlComments
- Provides a Twig filter that removes HTML comments from input.
Namespace
Drupal\twig_remove_html_comments\TwigExtensionCode
public function removeHtmlCommentsAsRenderArray(?string $string) : array {
if ($string !== NULL) {
$stringWithoutHtmlComments = $this
->removeHtmlCommentsFromString($string);
}
else {
$stringWithoutHtmlComments = '';
}
return [
'#markup' => $stringWithoutHtmlComments,
];
}