@@ -18,29 +18,27 @@ code.
18
18
Rendering a Template
19
19
--------------------
20
20
21
- Typically, you'll render a template from inside if your controller::
21
+ Typically, you'll render a template from inside of your controller::
22
22
23
23
// src/AppBundle/Controller/LuckyController.php
24
-
25
24
public function numberAction()
26
25
{
27
26
$number = mt_rand(0, 10);
28
27
29
28
// renders app/Resources/views/lucky/number.html.twig
30
29
return $this->render('lucky/number.html.twig', array(
31
- // pass a variable called randomNumber into the template
30
+ // pass two variables into your template
32
31
'randomNumber' => $number,
33
32
'people' => array('Javier', 'Christian, 'Wouter')
34
33
))
35
34
}
36
35
37
36
This template passes two variables - ``randomNumber `` and ``people `` into your
38
- template. A very simple template, might look like this:
37
+ template. A very simple template might look like this:
39
38
40
39
.. code-block :: html+twig
41
40
42
41
{# app/Resources/views/lucky/number.html.twig #}
43
-
44
42
<h1>Your lucky number: {{ randomNumber }}</h1>
45
43
46
44
<h3>Nice People:</h3>
@@ -63,7 +61,7 @@ Of course, this is only the beginning! Keep reading to learn more about
63
61
Twig Templates
64
62
--------------
65
63
66
- Symfony packages an powerful templating language called `Twig `_. With Twig, you can
64
+ Symfony packages a powerful templating language called `Twig `_. With Twig, you can
67
65
write concise, readable templates that are friendly to web designers and more powerful
68
66
than traditional PHP templates:
69
67
@@ -212,7 +210,7 @@ Check it out:
212
210
</body>
213
211
</html>
214
212
215
- This template defines a really basic HTML skeleton, which you should improve and
213
+ This template defines a basic HTML skeleton, which you should improve and
216
214
customize for your project. It also defines four **blocks **, identified with
217
215
``{% block %} `` (``title ``, ``stylesheets ``, ``body `` & ``javascripts ``).
218
216
@@ -756,8 +754,8 @@ advantage of Symfony's template inheritance.
756
754
757
755
Your ``base.html.twig `` base template already holds two blocks - ``stylesheets `` inside
758
756
the ``head `` tag and another called ``javascripts `` just above the closing ``body ``
759
- tag that are meant to hold your stylesheets and JavaScripts. Suppose first that
760
- you want include ``main.css `` and ``main.js `` files on every page on your site:
757
+ tag - that are meant to hold your stylesheets and JavaScripts. Suppose first that
758
+ you want to include ``main.css `` and ``main.js `` files on every page on your site:
761
759
762
760
.. configuration-block ::
763
761
0 commit comments