How to escape double curly braces in a blade template? I am trying to create a slideshow with thumbnails as shown at http://jquery.malsup.com/cycle2/demo/pager.php#adv-custom .
The markup I need to use is <img src='{{src}}' width=20 height=20>.
How can I escape the markup so that blade prints it with no errors?
I tried using {!! '{{src}}' !!} but it did not work.
<img src='@{{src}}' width=20 height=20>
@ escapes the curly brace for Blade compilation
Be careful with this!
This will work as expected:
@{{ foo }}
{{ $bar }}
But this won't:
@{{ }}
{{ $bar }}
$bar will be treated like normal text, rendering as:
{{ }}
{{ $bar }}
So if you want to make a random double curly braces, it will not work as expected:
Hey, I'm Johnny Moustache :@{{
{{ $bar }}
I think it's a bug.
@RoboRobok Well hopefully anpel hasn't had a bug in their code for a year+
Better late than never I guess.
He probably just uses it for templating, making it always closed. But it's interesting why it works that way, why it just doesn't ignore the curly braces when it's @{{.
I have no idea what project I needed this for or what I ended up doing. I will try to post an update when I get some more time though.
Please sign in or create an account to participate in this conversation.