@props([ 'content' => null, // what the field holds: HTML when $rich, plain text otherwise 'rich' => true, // whether that value is markup — usually a stored setting ]) {{-- The safe way to print a rich text field. It sanitises AGAIN, on the way out. That is not belt-and-braces paranoia about App\Support\RichText: it is the answer to everything that can put a row in the table without going through the editor — an installation that predates this component, a seeder, a DB::table()->update(), an import. The filter has to sit where the HTML meets the page, or the day one of those happens is the day a page starts executing somebody else's script. Plain values go through e() + nl2br instead, so a description written in a textarea keeps its line breaks and shows "" as the four characters the author typed. Prints into `.rf-richtext` — the same prose class the public CMS pages already use — so headings, lists and links render identically everywhere. --}} @php $html = $rich ? \App\Support\RichText::clean($content) : nl2br(e(trim((string) $content))); @endphp @if(filled($html))
merge(['class' => 'rf-richtext']) }}>{!! $html !!}
@endif