Search code examples
phplaravelviewsummernote

The view is not loading due to {{ }} in Laravel 5.7


I have setup summer-note.js on my textarea in my Laravel view, if I input any data and include {{}} this in the data and hit save button, the post saves successfully, but when I go to the show route the page is not loading at all after that I inspected it the body element was only showing, but when I viewed page source all code was displaying there, then I added a new data without {{}}, then I went to the show route, the page was loading fine, but when I include {{}} in the data, page doesn't load anymore, my Laravel view code:

<div class="col-md-8">
    <h1>Question # {{ $question->id }}:</h1>
    <p>{!! $question->question !!}</p>
</div>

I think it is due to double {{ {{ }} }} because when it renders data it becomes {{ This is {{question}} #1 }} so is there any fix of it?

I tried both {!! $question->question !!} and {{ $question->question }} but page was not loading.


Solution

  • Try to use jquery's replaceWith() function and put a restriction in there to convert the {{ }} to a HTML entity whenever it's found in the input.

    HTML entity for { is &#123; and for } is &#125;

    For more information, visit replaceWith() function and for HTML entities visit here