Search code examples
phplaravelsummernote

Why I can't display html from Summernote?


Hello everyone can you help me. I try to display HTML on .blade from Summernote text editor but it shows like this pic. This Pic


Solution

  • When outputting data in blade templates, if you use double curly braces {{ $data }} then the variable is passed through htmlspecialchars to prevent potential XSS attacks. This causes HTML to be output as a literal string.

    You can use {!! $data !!} to output data without this escaping.

    Laravel's documentation describes this pretty well; https://laravel.com/docs/8.x/blade#displaying-unescaped-data

    Do note the warning in the documentation:

    Be very careful when echoing content that is supplied by users of your application. You should typically use the escaped, double curly brace syntax to prevent XSS attacks when displaying user supplied data.