Home > Software design >  I am trying to add post to my blog post but when i added this the <p> tag appears also in my b
I am trying to add post to my blog post but when i added this the <p> tag appears also in my b

Time:06-29

In the blog code :

<div >
                    <h4><a href="blog-single.html">{{$post->title}}</a></h4>
                        {{$post->content}}
                    <div >
                        <span><i ></i><a href="#">{{$post->slug}}</a></span>
                        <span><i ></i>{{$post->created_at}}</span>
                    </div>
                </div>

In the CreateBlog :

<div > <i data-feather="chevron-down" ></i><label for="content-tab">Text Content</label> </div>
                                        <div  >
                                            <textarea name="content" id="content" ></textarea>
                                        </div>
                                    </div>

enter image description here

CodePudding user response:

You can use:

{!! $post->content !!}

CodePudding user response:

By default you would use the following syntax {{ $some_variable }} to echo out the content of a specific variable in Blade. By default the {{ }} escapes the HTML tags.

So let's say that you have a blog post with a $post collection which has some HTML elements in the body proerty, if you were to use the following:

<div>{{ $post->body }}</div>

All of the HTML tags would not be rendered as HTML but plain text.

If you don't want your HTML tags to be escaped then you should use {!! !!}

<div>{!! $post->body !!}</div>
  • Related