BKWLD / laravel-haml

Wraps MtHaml for ease use in Laravel
MIT License
45 stars 10 forks source link

Doing inline php in a haml file #19

Closed austinkregel closed 9 years ago

austinkregel commented 9 years ago

Hia, I was trying to do some inline php and for some reason the <? is trying to echo out. I'd love to be able to do my inline comparison.

This is what is in my haml.blade.php

@if($dev->status === "flash")
<?php $stat = "danger"?>
@else
<?php $stat = $dev->status; ?>
@endif
{!! '<span class="text-'.$stat.'"><i class="fa fa-'.$stat.'"></i></span>' !!}

And this is what it's being compiled into.

<?php if($dev->status === "flash"): ?>
<?php echo '<?'; ?>php $stat = "danger"?>
<?php else: ?>
<?php echo '<?'; ?>php $stat = $dev->status; ?>
<?php endif; ?>
<?php echo '<span class="text-'.$stat.'"><i class="fa fa-'.$stat.'"></i></span>'; ?>
weotch commented 9 years ago

In HAML, you do inline php with the :php filter. Like:

%span.text
  :php
    $stat = $dev->status;
    echo $stat;
austinkregel commented 9 years ago

Okay I'll give it a go for what I'm trying to accomplish.