@@ -136,7 +136,7 @@ the ``extend()`` call:
136136 <!-- app/Resources/views/Hello/index.html.php -->
137137 <?php $view->extend('AppBundle::layout.html.php') ?>
138138
139- Hello <?php echo $name ?>!
139+ Hello <?= $name ?>!
140140
141141The ``AppBundle::layout.html.php `` notation sounds familiar, doesn't it? It
142142is the same notation used to reference a template. The ``:: `` part simply
@@ -200,7 +200,7 @@ decorating the template. In the ``index.html.php`` template, define a
200200
201201 <?php $view['slots']->set('title', 'Hello World Application') ?>
202202
203- Hello <?php echo $name ?>!
203+ Hello <?= $name ?>!
204204
205205The base layout already has the code to output the title in the header:
206206
@@ -238,7 +238,7 @@ Create a ``hello.html.php`` template:
238238.. code-block :: html+php
239239
240240 <!-- app/Resources/views/Hello/hello.html.php -->
241- Hello <?php echo $name ?>!
241+ Hello <?= $name ?>!
242242
243243And change the ``index.html.php `` template to include it:
244244
@@ -247,7 +247,7 @@ And change the ``index.html.php`` template to include it:
247247 <!-- app/Resources/views/Hello/index.html.php -->
248248 <?php $view->extend('AppBundle::layout.html.php') ?>
249249
250- <?php echo $view->render('AppBundle:Hello: hello.html.php', array('name' => $name)) ?>
250+ <?= $view->render('AppBundle:Hello: hello.html.php', array('name' => $name)) ?>
251251
252252The ``render() `` method evaluates and returns the content of another template
253253(this is the exact same method as the one used in the controller).
@@ -268,7 +268,7 @@ If you create a ``fancy`` action, and want to include it into the
268268.. code-block :: html+php
269269
270270 <!-- app/Resources/views/Hello/index.html.php -->
271- <?php echo $view['actions']->render(
271+ <?= $view['actions']->render(
272272 new \S ymfony\C omponent\H ttpKernel\C ontroller\C ontrollerReference('AppBundle:Hello: fancy', array(
273273 'name' => $name,
274274 'color' => 'green',
@@ -320,7 +320,7 @@ updated by changing the configuration:
320320
321321.. code-block :: html+php
322322
323- <a href="<?php echo $view['router']->path('hello', array('name' => 'Thomas')) ?>">
323+ <a href="<?= $view['router']->path('hello', array('name' => 'Thomas')) ?>">
324324 Greet Thomas!
325325 </a>
326326
@@ -344,9 +344,9 @@ Symfony provides the ``assets`` tag to deal with them easily:
344344
345345.. code-block :: html+php
346346
347- <link href="<?php echo $view['assets']->getUrl('css/blog.css') ?>" rel="stylesheet" type="text/css" />
347+ <link href="<?= $view['assets']->getUrl('css/blog.css') ?>" rel="stylesheet" type="text/css" />
348348
349- <img src="<?php echo $view['assets']->getUrl('images/logo.png') ?>" />
349+ <img src="<?= $view['assets']->getUrl('images/logo.png') ?>" />
350350
351351The ``assets `` helper's main purpose is to make your application more
352352portable. Thanks to this helper, you can move the application root directory
@@ -374,13 +374,13 @@ Output Escaping
374374When using PHP templates, escape variables whenever they are displayed to the
375375user::
376376
377- <?php echo $view->escape($var) ?>
377+ <?= $view->escape($var) ?>
378378
379379By default, the ``escape() `` method assumes that the variable is outputted
380380within an HTML context. The second argument lets you change the context. For
381381instance, to output something in a JavaScript script, use the ``js `` context::
382382
383- <?php echo $view->escape($var, 'js') ?>
383+ <?= $view->escape($var, 'js') ?>
384384
385385Form Theming in PHP
386386-------------------
@@ -396,7 +396,7 @@ file in order to customize the ``integer_widget`` fragment.
396396
397397 <!-- app/Resources/views/form/integer_widget.html.php -->
398398 <div class="integer_widget">
399- <?php echo $view['form']->block(
399+ <?= $view['form']->block(
400400 $form,
401401 'form_widget_simple',
402402 array('type' => isset($type) ? $type : "number")
@@ -567,7 +567,7 @@ original template:
567567 <?php if ($required) { $label_attr['class'] = trim((isset($label_attr['class']) ? $label_attr['class'] : '').' required'); } ?>
568568 <?php if (!$compound) { $label_attr['for'] = $id; } ?>
569569 <?php if (!$label) { $label = $view['form']->humanize($name); } ?>
570- <label <?php foreach ($label_attr as $k => $v) { printf('%s="%s" ', $view->escape($k), $view->escape($v)); } ?>><?php echo $view->escape($view['translator']->trans($label, array(), $translation_domain)) ?></label>
570+ <label <?php foreach ($label_attr as $k => $v) { printf('%s="%s" ', $view->escape($k), $view->escape($v)); } ?>><?= $view->escape($view['translator']->trans($label, array(), $translation_domain)) ?></label>
571571
572572 <!-- customization -->
573573 <?php if ($required) : ?>
@@ -588,14 +588,14 @@ original template:
588588
589589 <!-- Original content -->
590590 <input
591- type="<?php echo isset($type) ? $view->escape($type) : 'text' ?>"
592- <?php if (!empty($value)): ?>value="<?php echo $view->escape($value) ?>"<?php endif ?>
593- <?php echo $view['form']->block($form, 'widget_attributes') ?>
591+ type="<?= isset($type) ? $view->escape($type) : 'text' ?>"
592+ <?php if (!empty($value)): ?>value="<?= $view->escape($value) ?>"<?php endif ?>
593+ <?= $view['form']->block($form, 'widget_attributes') ?>
594594 />
595595
596596 <!-- Customization -->
597597 <?php if (isset($help)) : ?>
598- <span class="help"><?php echo $view->escape($help) ?></span>
598+ <span class="help"><?= $view->escape($help) ?></span>
599599 <?php endif ?>
600600
601601.. _`@Template` : https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/view
0 commit comments