master

laravel/framework

Last updated at: 29/12/2023 09:25

CompilesComments.php

TLDR

This file is a trait for compiling Blade comments into an empty string.

Methods

compileComments($value)

This method takes a string value as an input and compiles Blade comments into an empty string. It uses regular expressions to identify Blade comments and replace them with an empty string.

Classes

None

<?php

namespace Illuminate\View\Compilers\Concerns;

trait CompilesComments
{
    /**
     * Compile Blade comments into an empty string.
     *
     * @param  string  $value
     * @return string
     */
    protected function compileComments($value)
    {
        $pattern = sprintf('/%s--(.*?)--%s/s', $this->contentTags[0], $this->contentTags[1]);

        return preg_replace($pattern, '', $value);
    }
}