Otterman
Otterman

Reputation: 530

Escaping trouble - Blade Template in Laravel 5.1

My view contains the following code

@foreach ($building as $maps)
    <div class="btn-group">
       <a class="btn btn-primary" role="button" href="{{ URL::asset('floorPlans/$maps') }}" aria-expanded="false" aria-controls="collapseExample">
          {{ $x }}
       </a>
    </div>
<?php $x++; ?>
@endforeach

Yet this is resulting in the follwoing HTML

<div class="btn-group">
   <a class="btn btn-primary" role="button" href="http://facilities-lara.hslc.wisc.edu/floorPlans/$maps" aria-expanded="false" aria-controls="collapseExample">2</a>
</div>

With $maps still being appended to URL instead of the value within $maps. Is it possible to retrieve the value within a blade template?

Thanks, Otterman

Upvotes: 1

Views: 123

Answers (1)

lukasgeiter
lukasgeiter

Reputation: 152880

Everything between the blade tags is just normal PHP. So you can simple concatenate the string and the variable:

{{ URL::asset('floorPlans/'.$maps) }}

Upvotes: 4

Related Questions