Skip to content

[Book] Fixed highlighting issues #2265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions book/controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ a controller object. Controllers are also called *actions*.
{
public function indexAction($name)
{
return new Response('<html><body>Hello '.$name.'!</body></html>');
return new Response('<html><body>Hello '.$name.'!</body></html>');
}
}

Expand Down Expand Up @@ -687,7 +687,7 @@ the ``notice`` message:
</div>
{% endif %}

.. code-block:: php
.. code-block:: html+php

<?php if ($view['session']->hasFlash('notice')): ?>
<div class="flash-notice">
Expand Down
10 changes: 5 additions & 5 deletions book/doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ information. By convention, this information is usually configured in an

; app/config/parameters.ini
[parameters]
database_driver = pdo_mysql
database_host = localhost
database_name = test_project
database_user = root
database_password = password
database_driver = pdo_mysql
database_host = localhost
database_name = test_project
database_user = root
database_password = password

.. note::

Expand Down
4 changes: 2 additions & 2 deletions book/http_cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ First, to use ESI, be sure to enable it in your application configuration:

// app/config/config.php
$container->loadFromExtension('framework', array(
...,
// ...
'esi' => array('enabled' => true),
));

Expand Down Expand Up @@ -884,7 +884,7 @@ matter), Symfony2 uses the standard ``render`` helper to configure ESI tags:

{% render url('latest_news', { 'max': 5 }) with {}, {'standalone': true} %}

.. code-block:: php
.. code-block:: html+php

<?php echo $view['actions']->render(
$view['router']->generate('latest_news', array('max' => 5), true),
Expand Down
4 changes: 2 additions & 2 deletions book/page_creation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ controller, and ``index.html.twig`` the template:
Hello {{ name }}!
{% endblock %}

.. code-block:: php
.. code-block:: html+php

<!-- src/Acme/HelloBundle/Resources/views/Hello/index.html.php -->
<?php $view->extend('::base.html.php') ?>
Expand Down Expand Up @@ -385,7 +385,7 @@ and in the ``app`` directory:
</body>
</html>

.. code-block:: php
.. code-block:: html+php

<!-- app/Resources/views/base.html.php -->
<!DOCTYPE html>
Expand Down
12 changes: 6 additions & 6 deletions book/propel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ information. By convention, this information is usually configured in an

; app/config/parameters.ini
[parameters]
database_driver = mysql
database_host = localhost
database_name = test_project
database_user = root
database_password = password
database_charset = UTF8
database_driver = mysql
database_host = localhost
database_name = test_project
database_user = root
database_password = password
database_charset = UTF8

.. note::

Expand Down
4 changes: 2 additions & 2 deletions book/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ a template helper function:
Read this blog post.
</a>

.. code-block:: php
.. code-block:: html+php

<a href="<?php echo $view['router']->generate('blog_show', array('slug' => 'my-blog-post')) ?>">
Read this blog post.
Expand All @@ -1185,7 +1185,7 @@ Absolute URLs can also be generated.
Read this blog post.
</a>

.. code-block:: php
.. code-block:: html+php

<a href="<?php echo $view['router']->generate('blog_show', array('slug' => 'my-blog-post'), true) ?>">
Read this blog post.
Expand Down
18 changes: 9 additions & 9 deletions book/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ Finally, create the corresponding template:

.. code-block:: html+php

<?php // src/Acme/SecurityBundle/Resources/views/Security/login.html.php ?>
<!-- src/Acme/SecurityBundle/Resources/views/Security/login.html.php -->
<?php if ($error): ?>
<div><?php echo $error->getMessage() ?></div>
<?php endif; ?>
Expand Down Expand Up @@ -723,7 +723,7 @@ You can define as many URL patterns as you need - each is a regular expression.

// app/config/security.php
$container->loadFromExtension('security', array(
...,
// ...
'access_control' => array(
array('path' => '^/admin/users', 'role' => 'ROLE_SUPER_ADMIN'),
array('path' => '^/admin', 'role' => 'ROLE_ADMIN'),
Expand Down Expand Up @@ -1072,7 +1072,7 @@ In fact, you've seen this already in the example in this chapter.

// app/config/security.php
$container->loadFromExtension('security', array(
...,
// ...
'providers' => array(
'default_provider' => array(
'users' => array(
Expand Down Expand Up @@ -1302,7 +1302,7 @@ configure the encoder for that user:

// app/config/security.php
$container->loadFromExtension('security', array(
...,
// ...
'encoders' => array(
'Acme\UserBundle\Entity\User' => 'sha512',
),
Expand Down Expand Up @@ -1502,10 +1502,10 @@ the first provider is always used:
$container->loadFromExtension('security', array(
'firewalls' => array(
'secured_area' => array(
...,
// ...
'provider' => 'user_db',
'http_basic' => array(
...,
// ...
'provider' => 'in_memory',
),
'form_login' => array(),
Expand Down Expand Up @@ -1616,7 +1616,7 @@ the firewall can handle this automatically for you when you activate the
$container->loadFromExtension('security', array(
'firewalls' => array(
'secured_area' => array(
...,
// ...
'logout' => array('path' => 'logout', 'target' => '/'),
),
),
Expand Down Expand Up @@ -1771,7 +1771,7 @@ done by activating the ``switch_user`` firewall listener:
$container->loadFromExtension('security', array(
'firewalls' => array(
'main'=> array(
...,
// ...
'switch_user' => true
),
),
Expand Down Expand Up @@ -1799,7 +1799,7 @@ to show a link to exit impersonation:
.. code-block:: html+jinja

{% if is_granted('ROLE_PREVIOUS_ADMIN') %}
<a href="{{ path('homepage', {_switch_user: '_exit'}) }}">Exit impersonation</a>
<a href="{{ path('homepage', { _switch_user: '_exit' }) }}">Exit impersonation</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not follow the Twig CS

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, I don't know why I did that... (will fix it soon)

{% endif %}

.. code-block:: html+php
Expand Down
20 changes: 14 additions & 6 deletions book/templating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1194,20 +1194,24 @@ this classic example:

.. configuration-block::

.. code-block:: jinja
.. code-block:: html+jinja

Hello {{ name }}

.. code-block:: html+php

Hello <?php echo $name ?>

Imagine that the user enters the following code as his/her name::
Imagine that the user enters the following code as his/her name:

.. code-block:: text

<script>alert('hello!')</script>

Without any output escaping, the resulting template will cause a JavaScript
alert box to pop up::
alert box to pop up:

.. code-block:: html

Hello <script>alert('hello!')</script>

Expand All @@ -1217,7 +1221,9 @@ inside the secure area of an unknowing, legitimate user.

The answer to the problem is output escaping. With output escaping on, the
same template will render harmlessly, and literally print the ``script``
tag to the screen::
tag to the screen:

.. code-block:: html

Hello &lt;script&gt;alert(&#39;helloe&#39;)&lt;/script&gt;

Expand Down Expand Up @@ -1249,7 +1255,9 @@ Output Escaping in PHP

Output escaping is not automatic when using PHP templates. This means that
unless you explicitly choose to escape a variable, you're not protected. To
use output escaping, use the special ``escape()`` view method::
use output escaping, use the special ``escape()`` view method:

.. code-block:: html+php

Hello <?php echo $view->escape($name) ?>

Expand All @@ -1258,7 +1266,7 @@ within an HTML context (and thus the variable is escaped to be safe for HTML).
The second argument lets you change the context. For example, to output something
in a JavaScript string, use the ``js`` context:

.. code-block:: js
.. code-block:: html+php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should actually be js+php (if it is supported)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stof I know, but that is not support. Even more, JS is not supported. That's why I changed it to html+php.


var myMsg = 'Hello <?php echo $view->escape($name, 'js') ?>';

Expand Down
4 changes: 3 additions & 1 deletion book/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ for its ``DemoController`` (`DemoControllerTest`_) that reads as follows::
kernel of your application. In most cases, this happens automatically.
However, if your kernel is in a non-standard directory, you'll need
to modify your ``phpunit.xml.dist`` file to set the ``KERNEL_DIR`` environment
variable to the directory of your kernel::
variable to the directory of your kernel:

.. code-block:: xml

<phpunit>
<!-- ... -->
Expand Down