Reputation: 4490
How can I escape something in Blade templating within PHP for CSS.
Let me explain: I have several divs (12 boxes) and I want this div to have a background. Its loaded with an foreach so every box will have its own background (and some more info).
When I try:
<div class="box" style="background-image: url('http://localhost:8080/Artist%20Agency/artistlaravel/{{$cat[0][\"picture\"]}}');">
The following error:
syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_STRING
When I do:
<div class="box" style="background-image: url('http://localhost:8080/Artist%20Agency/artistlaravel/{{$cat[0]['picture']}}');">
No Error at all, it just doesn't work. The url that gets generated is:
http://localhost:8080/Artist%20Agency/artistlaravel/uploads\CATEGORY_ZangersPsakKDURhFlo.jpg
And appearantly that doesn't work either. When I copy this link to my browser it works. But in the code it doesn't work. When I do the following, it works. But that is not dynamic...
<div class="box" style="background-image: url('http://localhost:8080/Artist%20Agency/artistlaravel/uploads/CATEGORY_ZangersPsakKDURhFlo.jpg');">
How do I do this?
Upvotes: 0
Views: 162
Reputation: 212412
There's a big difference in blade between
{{ $value }}
and
{{{ $value }}}
The latter escapes, the former doesn't
Upvotes: 2