Search code examples
phpeclipsecakephpeclipse-pdt

How to auto format code file *.ctp in PDT Helios?


I am using Eclipse for PHP (PDT) Helios, how to auto format CakePHP Template file?

For example: when I follow this tutorial , when I edit file index.ctp like this:

<!-- File: /app/View/Posts/index.ctp -->

<h1>Blog posts</h1>
<table>
    <tr>
        <th>Id</th>
        <th>Title</th>
        <th>Created</th>
    </tr>

    <!-- Here is where we loop through our $posts array, printing out post info -->

    <?php foreach ($posts as $post): ?>
    <tr>
        <td><?php echo $post['Post']['id']; ?></td>
        <td>
            <?php echo $this->Html->link($post['Post']['title'],
array('controller' => 'posts', 'action' => 'view', $post['Post']['id'])); ?>
        </td>
        <td><?php echo $post['Post']['created']; ?></td>
    </tr>
    <?php endforeach; ?>
    <?php unset($post); ?>
</table>

I don't undestand how Eclipse autoformat above snippet code. Please help me, thank you!


Solution

  • I do this like my follow screenshot:

    enter image description here