i hope you're having a good day.
i have some raw html that i want to render inside my blade file,
ive tried the {!!...!!} syntax but for some reason it is not working for me, when i use this
{ !! $jobs[0]->content !!}
i get this result
My laravel version is >8.
Thank you for your answer.
The syntax is without the space. Removing your leading space will solve your issue.
{!! $jobs[0]->content !!}
https://laravel.com/docs/8.x/blade#displaying-unescaped-data
Related
{!! Menu::render('admin-sidebar-menu', 'adminltecustom'); !!}
I am editing a laravel code and want to make canges in my sidebar. but i donot understand this line, and I cannot find the source of sidebar.
Anyone who can help me out what does it actually means. and how can I edit my sidebar of the project.
The blade Syntax {!! !!}
is used to used to print HTML as it is without escaping it.
Use it cautiously as it is used to avoid escaping data, and can be result in security failures if used incorrectly.
Normally, v-html in vue would solve this issue, I dont know how to get around it using blade. Note, if i use the mustache syntax it would show the contents with the tags and thats not okay.. Please any help is appreciated
You need to use {!! !!} instead of {{ }}
{!! $content !!}
https://laravel.com/docs/8.x/blade#displaying-unescaped-data
#Asking
Help me for my problem, when i built a website with Laravel
i am render my post with syntax like this :
<div>
<p>{!! $post->content !!}</p>
</div>
but i have problem, when i insert a i frame inside post, because the html has been removed with {!! !!}.
i have to try use {{ $post->content }}, but all content rendered with HTML
Any solution to this problem? ?
Thanks very much
With {!! you paste content "as is", in other words you become vulnerable to all types of issues like allowing <script> tags to be placed into your templates.
The {{ syntax will escape any HTML thus what you see is the actual html characters without actually parsing it (i.e. doing {{ '<b>bold</b>' }} will not result in a bold font but in the text <b>bold</b>).
Now with your problem: there are some cumbersome ways to filter out any html tags yourself and leave the <iframe>'s in there (something like {!! only_iframe($content) !!}), but it is quite difficult and will likely not result in a safe solution.
Your own answer which stated that you used {!!html_entity_decode($post->content)!!} simply means that your HTML was encoded to start with, which is not something I can deduct from your question. Note that you are now vulnerable to malicious code injection if you are not certain you can control the contents of $post->content.
I wanna put an image path in may laravel code like this
{!!Html::image({{$mdata->company_logo}},'logo',['width'=>60,'height'=>55])!!}
but {{$mdata->company_logo}} gives an error to html::image. I'm sure that image path from $mdata->company_logo has a valid data, namely the image path, because I can see it by using dd($data->company_logo).. But why html::image can't show the image...??
Thanks in advance.. :)
You shouldn't put the {{ }} around the $mdata->company_logo.
You are already inside a php block by using {!! !!} around Html::image().
Try {!!Html::image($mdata->company_logo,'logo',['width'=>60,'height'=>55])!!}.
I am going to use AngularJS along with Laravel, and I wanted to change Laravel tags to [[ ]] (which I think BTW is nicer since [ ] looks more like blade and is sharper :p )
Anyhow, I changed it with
Blade::setContentTags('[[', ']]'); // for variables and all things Blade
Blade::setEscapedContentTags('[[[', ']]]'); // for escaped data
How do I change the "Bracket Highlight" in Sublime now so that it still highlights my new tags??
Not directly answerting your question, but my solution to have Angular and Blade playing nice is very simple, I create a _partial every time I need some Angular and name this partial just '.php' and not '.blade.php', so if I have a form that uses Angular, I have:
{{ Form::open() }}
#include('_partials.posts.forms.create');
{{ Form::close() }}
In this case the included file would be views/_partials/posts/forms/create.php.
About Sublime, download Blade Syntax Highlighter, this file might give you a clue about how to change that for you:
https://github.com/Medalink/laravel-blade/blob/master/laravel-blade.tmLanguage