smarteist/PHP2Blade

What PHP directives does PHP2Blade translate to its blade form?

Opened this issue · 2 comments

For example I was expecting

<?php echo 'this is my name:'.my_name();?>

to be transpiled to
This is {{my_name()}}

I see now using a different control structure might solve the problem. Because this is happening inside a PHP code block.

My current code:

 <?php
  if (!$category_as_link)
  {
       echo $this->ad_model->adCategoryString($ad);
  } else
  {
          echo $this->ad_model->category_link($ad);
   }
 ?>

The output from PHP2Blade is just an entire @php codeblock

@php if (!$category_as_link)
{
     echo $ci->ad_model->adCategoryString($ad);
} else
{
    echo $ci->ad_model->category_link($ad);
} 
@endphp

I will try the alternative control structure syntax which you mention in the previous issue, this means adding a LOT of opening and closing PHP tags to my current code unfortunately, I imagine so:

<?php if (!$category_as_link): ?>
<?php  echo $this->ad_model->adCategoryString($ad);  ?>
<?php else: ?>
<?php  $this->ad_model->category_link($ad); ?>
<?php  endelse; ?>

Okay turns out not all the extra php open and closing tags are not necessary.

This transpiled correctly:

 <?php if(!$category_as_link): ?>
    echo $this->ad_model->adCategoryString($ad);
  else:
    ehco $this->ad_model->category_link($ad);
  endif;?>

This will be a LOT of refactoring with hundreds of templates and will see if I can solve this with find/replace using regexs.

HEREDOC looks also to work luckily, this will save a lot of work.