Permalink
Browse files

minor #4436 remove semicolons in PHP templates (xabbuh)

This PR was merged into the 2.3 branch.

Discussion
----------

remove semicolons in PHP templates

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | all
| Fixed tickets |

Commits
-------

3d07e1a remove semicolons in PHP templates
  • Loading branch information...
wouterj committed Nov 8, 2014
2 parents 97c4b2e + 3d07e1a commit 5d6d0c2c16178a214e67ffa2fbaac7879f53e54d
@@ -736,7 +736,7 @@ the ``notice`` message:
<div class="flash-notice">
<?php echo "<div class='flash-error'>$message</div>" ?>
</div>
<?php endforeach; ?>
<?php endforeach ?>
By design, flash messages are meant to live for exactly one request (they're
"gone in a flash"). They're designed to be used across redirects exactly as
@@ -49,7 +49,7 @@ persisted to the database. Writing in flat PHP is quick and dirty:
<?php echo $row['title'] ?>
</a>
</li>
<?php endwhile; ?>
<?php endwhile ?>
</ul>
</body>
</html>
@@ -121,7 +121,7 @@ is primarily an HTML file that uses a template-like PHP syntax:
<?php echo $post['title'] ?>
</a>
</li>
<?php endforeach; ?>
<?php endforeach ?>
</ul>
</body>
</html>
@@ -238,7 +238,7 @@ the layout:
<?php echo $post['title'] ?>
</a>
</li>
<?php endforeach; ?>
<?php endforeach ?>
</ul>
<?php $content = ob_get_clean() ?>
@@ -603,7 +603,7 @@ database and the Templating component to render a template and return a
<?php echo $post->getTitle() ?>
</a>
</li>
<?php endforeach; ?>
<?php endforeach ?>
</ul>
The layout is nearly identical:
@@ -512,7 +512,7 @@ Finally, create the corresponding template:
<!-- src/Acme/SecurityBundle/Resources/views/Security/login.html.php -->
<?php if ($error): ?>
<div><?php echo $error->getMessage() ?></div>
<?php endif; ?>
<?php endif ?>
<form action="<?php echo $view['router']->generate('login_check') ?>" method="post">
<label for="username">Username:</label>
@@ -1803,7 +1803,7 @@ the built-in helper function:
<?php if ($view['security']->isGranted('ROLE_ADMIN')): ?>
<a href="...">Delete</a>
<?php endif; ?>
<?php endif ?>
.. note::
@@ -46,7 +46,7 @@ template - a text file parsed by PHP that contains a mix of text and PHP code:
<?php echo $item->getCaption() ?>
</a>
</li>
<?php endforeach; ?>
<?php endforeach ?>
</ul>
</body>
</html>
@@ -233,7 +233,7 @@ First, build a base layout file:
<li><a href="/">Home</a></li>
<li><a href="/blog">Blog</a></li>
</ul>
<?php endif; ?>
<?php endif ?>
</div>
<div id="content">
@@ -283,7 +283,7 @@ A child template might look like this:
<?php foreach ($blog_entries as $entry): ?>
<h2><?php echo $entry->getTitle() ?></h2>
<p><?php echo $entry->getBody() ?></p>
<?php endforeach; ?>
<?php endforeach ?>
<?php $view['slots']->stop() ?>
.. note::
@@ -637,7 +637,7 @@ The ``recentList`` template is perfectly straightforward:
<a href="/article/<?php echo $article->getSlug() ?>">
<?php echo $article->getTitle() ?>
</a>
<?php endforeach; ?>
<?php endforeach ?>
.. note::
@@ -967,7 +967,7 @@ correctly:
)) ?>">
<?php echo $article->getTitle() ?>
</a>
<?php endforeach; ?>
<?php endforeach ?>
.. tip::
@@ -1141,7 +1141,7 @@ automatically:
<?php if ($app->getDebug()): ?>
<p>Request method: <?php echo $app->getRequest()->getMethod() ?></p>
<p>Application Environment: <?php echo $app->getEnvironment() ?></p>
<?php endif; ?>
<?php endif ?>
.. tip::
@@ -192,7 +192,7 @@ Inside the template, you can output the list of errors exactly as needed:
<ul>
<?php foreach ($errors as $error): ?>
<li><?php echo $error->getMessage() ?></li>
<?php endforeach; ?>
<?php endforeach ?>
</ul>
.. note::
@@ -70,7 +70,7 @@ templates:
array('coffee')
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>" type="text/javascript"></script>
<?php endforeach; ?>
<?php endforeach ?>
This is all that's needed to compile this CoffeeScript file and serve it
as the compiled JavaScript.
@@ -100,7 +100,7 @@ You can also combine multiple CoffeeScript files into a single output file:
array('coffee')
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>" type="text/javascript"></script>
<?php endforeach; ?>
<?php endforeach ?>
Both the files will now be served up as a single file compiled into regular
JavaScript.
@@ -186,4 +186,4 @@ being run through the CoffeeScript filter):
)
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>" type="text/javascript"></script>
<?php endforeach; ?>
<?php endforeach ?>
@@ -69,7 +69,7 @@ To include JavaScript files, use the ``javascripts`` tag in any template:
array('@AcmeFooBundle/Resources/public/js/*')
) as $url): ?>
<script type="text/javascript" src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach; ?>
<?php endforeach ?>
.. note::
@@ -126,7 +126,7 @@ above, except with the ``stylesheets`` tag:
array('cssrewrite')
) as $url): ?>
<link rel="stylesheet" href="<?php echo $view->escape($url) ?>" />
<?php endforeach; ?>
<?php endforeach ?>
.. note::
@@ -178,7 +178,7 @@ To include an image you can use the ``image`` tag.
array('@AcmeFooBundle/Resources/public/images/example.jpg')
) as $url): ?>
<img src="<?php echo $view->escape($url) ?>" alt="Example" />
<?php endforeach; ?>
<?php endforeach ?>
You can also use Assetic for image optimization. More information in
:doc:`/cookbook/assetic/jpeg_optimize`.
@@ -231,7 +231,7 @@ but still serve them as a single file:
)
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach; ?>
<?php endforeach ?>
In the ``dev`` environment, each file is still served individually, so that
you can debug problems more easily. However, in the ``prod`` environment
@@ -268,7 +268,7 @@ combine third party assets, such as jQuery, with your own into a single file:
)
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach; ?>
<?php endforeach ?>
Using Named Assets
~~~~~~~~~~~~~~~~~~
@@ -341,7 +341,7 @@ with the ``@named_asset`` notation:
)
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach; ?>
<?php endforeach ?>
.. _cookbook-assetic-filters:
@@ -417,7 +417,7 @@ into your template:
array('uglifyjs2')
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach; ?>
<?php endforeach ?>
A more detailed guide about configuring and using Assetic filters as well as
details of Assetic's debug mode can be found in :doc:`/cookbook/assetic/uglifyjs`.
@@ -444,7 +444,7 @@ done from the template and is relative to the public document root:
array('output' => 'js/compiled/main.js')
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach; ?>
<?php endforeach ?>
.. note::
@@ -567,4 +567,4 @@ some isolated directory (e.g. ``/js/compiled``), to keep things organized:
array('output' => 'js/compiled/main.js')
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach; ?>
<?php endforeach ?>
@@ -69,7 +69,7 @@ It can now be used from a template:
array('jpegoptim')
) as $url): ?>
<img src="<?php echo $view->escape($url) ?>" alt="Example"/>
<?php endforeach; ?>
<?php endforeach ?>
Removing all EXIF Data
~~~~~~~~~~~~~~~~~~~~~~
@@ -133,7 +133,7 @@ can configure its location using the ``node`` key:
.. code-block:: xml
<!-- app/config/config.xml -->
<assetic:config
<assetic:config
node="/usr/bin/nodejs" >
<assetic:filter
name="uglifyjs2"
@@ -172,7 +172,7 @@ your assets are a part of the view layer, this work is done in your templates:
array('uglifyj2s')
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach; ?>
<?php endforeach ?>
.. note::
@@ -208,7 +208,7 @@ apply this filter when debug mode is off (e.g. ``app.php``):
array('?uglifyjs2')
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach; ?>
<?php endforeach ?>
To try this out, switch to your ``prod`` environment (``app.php``). But before
you do, don't forget to :ref:`clear your cache <book-page-creation-prod-cache-clear>`
@@ -284,7 +284,7 @@ helper:
array('cssrewrite')
) as $url): ?>
<link rel="stylesheet" href="<?php echo $view->escape($url) ?>" />
<?php endforeach; ?>
<?php endforeach ?>
Just like with the ``uglifyjs2`` filter, if you prefix the filter name with
``?`` (i.e. ``?uglifycss``), the minification will only happen when you're
@@ -102,7 +102,7 @@ the view layer, this work is done in your templates:
array('yui_js')
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach; ?>
<?php endforeach ?>
.. note::
@@ -130,7 +130,7 @@ can be repeated to minify your stylesheets.
array('yui_css')
) as $url): ?>
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo $view->escape($url) ?>" />
<?php endforeach; ?>
<?php endforeach ?>
Disable Minification in Debug Mode
----------------------------------
@@ -156,7 +156,7 @@ apply this filter when debug mode is off.
array('?yui_js')
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach; ?>
<?php endforeach ?>
.. tip::
@@ -226,7 +226,7 @@ zero tags when first created).
<ul class="tags">
<?php foreach($form['tags'] as $tag): ?>
<li><?php echo $view['form']->row($tag['name']) ?></li>
<?php endforeach; ?>
<?php endforeach ?>
</ul>
<?php echo $view['form']->end($form) ?>
@@ -795,7 +795,7 @@ and customize the ``form_errors`` fragment.
<ul>
<?php foreach ($errors as $error): ?>
<li><?php echo $error->getMessage() ?></li>
<?php endforeach; ?>
<?php endforeach ?>
</ul>
<?php endif ?>
@@ -860,11 +860,11 @@ fields (e.g. a whole form), and not just an individual field.
<ul>
<?php foreach ($errors as $error): ?>
<li><?php echo $error->getMessage() ?></li>
<?php endforeach; ?>
<?php endforeach ?>
</ul>
<?php else: ?>
<!-- ... render the errors for a single field -->
<?php endif; ?>
<?php endif ?>
<?php endif ?>
@@ -213,7 +213,7 @@ redirect to the URL defined by some ``account`` route, use the following:
<!-- src/Acme/SecurityBundle/Resources/views/Security/login.html.php -->
<?php if ($error): ?>
<div><?php echo $error->getMessage() ?></div>
<?php endif; ?>
<?php endif ?>
<form action="<?php echo $view['router']->generate('login_check') ?>" method="post">
<label for="username">Username:</label>
@@ -84,7 +84,7 @@ to show a link to exit impersonation:
>
Exit impersonation
</a>
<?php endif; ?>
<?php endif ?>
Of course, this feature needs to be made available to a small group of users.
By default, access is restricted to users having the ``ROLE_ALLOWED_TO_SWITCH``
@@ -90,7 +90,7 @@ might ultimately looks like this:
<!-- src/Acme/SecurityBundle/Resources/views/Security/login.html.php -->
<?php if ($error): ?>
<div><?php echo $error->getMessage() ?></div>
<?php endif; ?>
<?php endif ?>
<form action="<?php echo $view['router']->generate('login_check') ?>" method="post">
<label for="username">Username:</label>
@@ -101,7 +101,7 @@ A much more flexible method would look like this:
<?php echo $view['form']->errors($emailField) ?>
<?php echo $view['form']->widget($emailField) ?>
</li>
<?php endforeach; ?>
<?php endforeach ?>
</ul>
In both cases, no input fields would render unless your ``emails`` data array

0 comments on commit 5d6d0c2

Please sign in to comment.