Skip to content

Commit a455e7a

Browse files
committed
Merge branch '2.8' into 3.4
* 2.8: Removed more PHP template examples
2 parents f33473f + 3e93523 commit a455e7a

File tree

14 files changed

+248
-749
lines changed

14 files changed

+248
-749
lines changed

controller.rst

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -526,47 +526,25 @@ you'll use this key to retrieve the message.
526526
In the template of the next page (or even better, in your base layout template),
527527
read any flash messages from the session using ``app.flashes()``:
528528

529-
.. configuration-block::
529+
.. code-block:: html+twig
530530

531-
.. code-block:: html+twig
531+
{# app/Resources/views/base.html.twig #}
532532

533-
{# app/Resources/views/base.html.twig #}
533+
{# you can read and display just one flash message type... #}
534+
{% for message in app.flashes('notice') %}
535+
<div class="flash-notice">
536+
{{ message }}
537+
</div>
538+
{% endfor %}
534539

535-
{# you can read and display just one flash message type... #}
536-
{% for message in app.flashes('notice') %}
537-
<div class="flash-notice">
540+
{# ...or you can read and display every flash message available #}
541+
{% for label, messages in app.flashes %}
542+
{% for message in messages %}
543+
<div class="flash-{{ label }}">
538544
{{ message }}
539545
</div>
540546
{% endfor %}
541-
542-
{# ...or you can read and display every flash message available #}
543-
{% for label, messages in app.flashes %}
544-
{% for message in messages %}
545-
<div class="flash-{{ label }}">
546-
{{ message }}
547-
</div>
548-
{% endfor %}
549-
{% endfor %}
550-
551-
.. code-block:: html+php
552-
553-
<!-- app/Resources/views/base.html.php -->
554-
555-
// you can read and display just one flash message type...
556-
<?php foreach ($view['session']->getFlashBag()->get('notice') as $message): ?>
557-
<div class="flash-notice">
558-
<?php echo $message ?>
559-
</div>
560-
<?php endforeach ?>
561-
562-
// ...or you can read and display every flash message available
563-
<?php foreach ($view['session']->getFlashBag()->all() as $type => $flash_messages): ?>
564-
<?php foreach ($flash_messages as $flash_message): ?>
565-
<div class="flash-<?php echo $type ?>">
566-
<?php echo $message ?>
567-
</div>
568-
<?php endforeach ?>
569-
<?php endforeach ?>
547+
{% endfor %}
570548

571549
.. versionadded:: 3.3
572550
The ``app.flashes()`` Twig function was introduced in Symfony 3.3. Prior,

forms.rst

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -139,21 +139,12 @@ done by passing a special form "view" object to your template (notice the
139139
``$form->createView()`` in the controller above) and using a set of form
140140
helper functions:
141141

142-
.. configuration-block::
143-
144-
.. code-block:: html+twig
145-
146-
{# app/Resources/views/default/new.html.twig #}
147-
{{ form_start(form) }}
148-
{{ form_widget(form) }}
149-
{{ form_end(form) }}
150-
151-
.. code-block:: html+php
142+
.. code-block:: html+twig
152143

153-
<!-- app/Resources/views/default/new.html.php -->
154-
<?php echo $view['form']->start($form) ?>
155-
<?php echo $view['form']->widget($form) ?>
156-
<?php echo $view['form']->end($form) ?>
144+
{# app/Resources/views/default/new.html.twig #}
145+
{{ form_start(form) }}
146+
{{ form_widget(form) }}
147+
{{ form_end(form) }}
157148

158149
.. image:: /_images/form/simple-form.png
159150
:align: center
@@ -413,21 +404,12 @@ Validation is a very powerful feature of Symfony and has its own
413404
but are being prevented by your browser from, for example, submitting
414405
blank fields.
415406

416-
.. configuration-block::
417-
418-
.. code-block:: html+twig
419-
420-
{# app/Resources/views/default/new.html.twig #}
421-
{{ form_start(form, {'attr': {'novalidate': 'novalidate'}}) }}
422-
{{ form_widget(form) }}
423-
{{ form_end(form) }}
424-
425-
.. code-block:: html+php
407+
.. code-block:: html+twig
426408

427-
<!-- app/Resources/views/default/new.html.php -->
428-
<?php echo $view['form']->start($form, array('attr' => array('novalidate' => 'novalidate') ?>
429-
<?php echo $view['form']->widget($form) ?>
430-
<?php echo $view['form']->end($form) ?>
409+
{# app/Resources/views/default/new.html.twig #}
410+
{{ form_start(form, {'attr': {'novalidate': 'novalidate'}}) }}
411+
{{ form_widget(form) }}
412+
{{ form_end(form) }}
431413

432414
.. index::
433415
single: Forms; Built-in field types

frontend/assetic/apply_to_option.rst

Lines changed: 18 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,11 @@ Filter a single File
6767
You can now serve up a single CoffeeScript file as JavaScript from within your
6868
templates:
6969

70-
.. configuration-block::
71-
72-
.. code-block:: html+twig
73-
74-
{% javascripts '@AppBundle/Resources/public/js/example.coffee' filter='coffee' %}
75-
<script src="{{ asset_url }}"></script>
76-
{% endjavascripts %}
70+
.. code-block:: html+twig
7771

78-
.. code-block:: html+php
79-
80-
<?php foreach ($view['assetic']->javascripts(
81-
array('@AppBundle/Resources/public/js/example.coffee'),
82-
array('coffee')
83-
) as $url): ?>
84-
<script src="<?php echo $view->escape($url) ?>"></script>
85-
<?php endforeach ?>
72+
{% javascripts '@AppBundle/Resources/public/js/example.coffee' filter='coffee' %}
73+
<script src="{{ asset_url }}"></script>
74+
{% endjavascripts %}
8675

8776
This is all that's needed to compile this CoffeeScript file and serve it
8877
as the compiled JavaScript.
@@ -92,27 +81,13 @@ Filter multiple Files
9281

9382
You can also combine multiple CoffeeScript files into a single output file:
9483

95-
.. configuration-block::
96-
97-
.. code-block:: html+twig
84+
.. code-block:: html+twig
9885

99-
{% javascripts '@AppBundle/Resources/public/js/example.coffee'
100-
'@AppBundle/Resources/public/js/another.coffee'
101-
filter='coffee' %}
102-
<script src="{{ asset_url }}"></script>
103-
{% endjavascripts %}
104-
105-
.. code-block:: html+php
106-
107-
<?php foreach ($view['assetic']->javascripts(
108-
array(
109-
'@AppBundle/Resources/public/js/example.coffee',
110-
'@AppBundle/Resources/public/js/another.coffee',
111-
),
112-
array('coffee')
113-
) as $url): ?>
114-
<script src="<?php echo $view->escape($url) ?>"></script>
115-
<?php endforeach ?>
86+
{% javascripts '@AppBundle/Resources/public/js/example.coffee'
87+
'@AppBundle/Resources/public/js/another.coffee'
88+
filter='coffee' %}
89+
<script src="{{ asset_url }}"></script>
90+
{% endjavascripts %}
11691

11792
Both files will now be served up as a single file compiled into regular JavaScript.
11893

@@ -188,24 +163,12 @@ template. You can also list regular JavaScript files, all of which will be
188163
combined and rendered as a single JavaScript file (with only the ``.coffee``
189164
files being run through the CoffeeScript filter):
190165

191-
.. configuration-block::
166+
.. code-block:: html+twig
167+
168+
{% javascripts '@AppBundle/Resources/public/js/example.coffee'
169+
'@AppBundle/Resources/public/js/another.coffee'
170+
'@AppBundle/Resources/public/js/regular.js' %}
171+
<script src="{{ asset_url }}"></script>
172+
{% endjavascripts %}
173+
192174

193-
.. code-block:: html+twig
194-
195-
{% javascripts '@AppBundle/Resources/public/js/example.coffee'
196-
'@AppBundle/Resources/public/js/another.coffee'
197-
'@AppBundle/Resources/public/js/regular.js' %}
198-
<script src="{{ asset_url }}"></script>
199-
{% endjavascripts %}
200-
201-
.. code-block:: html+php
202-
203-
<?php foreach ($view['assetic']->javascripts(
204-
array(
205-
'@AppBundle/Resources/public/js/example.coffee',
206-
'@AppBundle/Resources/public/js/another.coffee',
207-
'@AppBundle/Resources/public/js/regular.js',
208-
)
209-
) as $url): ?>
210-
<script src="<?php echo $view->escape($url) ?>"></script>
211-
<?php endforeach ?>

0 commit comments

Comments
 (0)