Skip to content

[Reference][Twig] Fix typos and formatting #3159

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 3 commits into from
Nov 7, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 1 addition & 2 deletions reference/forms/twig_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ object:

.. code-block:: html+jinja

<label for="{{ form.name.vars.id }}"
class="{{ form.name.vars.required ? 'required' : '' }}">
<label for="{{ form.name.vars.id }}" class="{{ form.name.vars.required ? 'required' : '' }}">
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't help. The syntax highlighting doesn't work because of the twig condition inside the class attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, but what's wrong with the ternary operator - seems to be valid Twig syntax?

Copy link
Member

Choose a reason for hiding this comment

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

The issue is that Pygments does not support highlighting Twig. It supports highlighting Jinja (a Python templating language).

And being written for Python devs, Jinja does not support this ternary operator. Instead, it has inline if expressions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for this info. So either I revert this change or I fix it with an regular if statement.

Copy link
Member

Choose a reason for hiding this comment

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

I suggest keeping it as it was. This is valid Twig markup.

Copy link
Member

Choose a reason for hiding this comment

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

+1 for keeping the original

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Restored.

{{ form.name.vars.label }}
</label>

Expand Down
22 changes: 11 additions & 11 deletions reference/twig_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Functions
| ``render(path('route', {params}))`` | |
| ``render(url('route', {params}))`` | |
+----------------------------------------------------+--------------------------------------------------------------------------------------------+
| ``render_esi(controller('B:C:a', {params}))`` | This will generates an ESI tag when possible or fallback to the ``render`` |
| ``render_esi(controller('B:C:a', {params}))`` | This will generate an ESI tag when possible or fallback to the ``render`` |
| ``render_esi(url('route', {params}))`` | behavior otherwise. For more information, see :ref:`templating-embedding-controller`. |
| ``render_esi(path('route', {params}))`` | |
+----------------------------------------------------+--------------------------------------------------------------------------------------------+
Expand Down Expand Up @@ -75,28 +75,28 @@ Functions
+----------------------------------------------------+--------------------------------------------------------------------------------------------+
| ``logout_path(key)`` | This will generate the relative logout URL for the given firewall |
+----------------------------------------------------+--------------------------------------------------------------------------------------------+
| ``logout_url(key)`` | Equal to ``logout_path(...)`` but this will generate an absolute url |
| ``logout_url(key)`` | Equal to ``logout_path(...)`` but this will generate an absolute URL |
+----------------------------------------------------+--------------------------------------------------------------------------------------------+
| ``path(name, parameters = {})`` | Get a relative url for the given route, more information in |
| ``path(name, parameters = {})`` | Get a relative URL for the given route, more information in |
| | ":ref:`book-templating-pages`". |
+----------------------------------------------------+--------------------------------------------------------------------------------------------+
| ``url(name, parameters = {})`` | Equal to ``path(...)`` but it generates an absolute url |
| ``url(name, parameters = {})`` | Equal to ``path(...)`` but it generates an absolute URL |
+----------------------------------------------------+--------------------------------------------------------------------------------------------+

Filters
-------

.. versionadded:: 2.1
The ``humanize`` filter was added in Symfony2.1
The ``humanize`` filter was added in Symfony 2.1

+---------------------------------------------------------------------------------+-------------------------------------------------------------------+
| Filter Syntax | Usage |
+=================================================================================+===================================================================+
| ``text|humanize`` | Makes a technical name human readable (replaces underscores by |
| | spaces and capitalizes the string) |
| | spaces and capitalizes the string). |
+---------------------------------------------------------------------------------+-------------------------------------------------------------------+
| ``text|trans(arguments = {}, domain = 'messages', locale = null)`` | This will translate the text into the current language, more |
| | information in . |
| | information in |
| | :ref:`Translation Filters <book-translation-filters>`. |
+---------------------------------------------------------------------------------+-------------------------------------------------------------------+
| ``text|transchoice(count, arguments = {}, domain = 'messages', locale = null)`` | This will translate the text with pluralization, more information |
Expand Down Expand Up @@ -165,8 +165,8 @@ Global Variables
+-------------------------------------------------------+------------------------------------------------------------------------------------+
| Variable | Usage |
+=======================================================+====================================================================================+
| ``app`` *Attributes*: ``app.user``, ``app.request`` | The ``app`` variable is available everywhere, and gives you quick |
| ``app.session``, ``app.environment``, ``app.debug`` | access to many commonly needed objects. The ``app`` variable is |
| ``app`` *Attributes*: ``app.user``, ``app.request``, | The ``app`` variable is available everywhere, and gives you quick |
| ``app.session``, ``app.environment``, ``app.debug``, | access to many commonly needed objects. The ``app`` variable is |
| ``app.security`` | instance of :class:`Symfony\\Bundle\\FrameworkBundle\\Templating\\GlobalVariables` |
+-------------------------------------------------------+------------------------------------------------------------------------------------+

Expand All @@ -178,10 +178,10 @@ Those bundles can have other Twig extensions:

* **Twig Extension** includes all extensions that do not belong to the
Copy link
Member

Choose a reason for hiding this comment

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

I would change this wording. There is potentially lots of interesting Twig extensions which are not in Fabien's repo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have a look at my update, hope that's okay.

Twig core but can be interesting. You can read more in
`the official Twig Extensions documentation`_
`the official Twig Extensions documentation`_;
* **Assetic** adds the ``{% stylesheets %}``, ``{% javascripts %}`` and
``{% image %}`` tags. You can read more about them in
:doc:`the Assetic Documentation </cookbook/assetic/asset_management>`;
:doc:`the Assetic Documentation </cookbook/assetic/asset_management>`.

.. _`the official Twig Extensions documentation`: http://twig.sensiolabs.org/doc/extensions/index.html
.. _`http://twig.sensiolabs.org/documentation`: http://twig.sensiolabs.org/documentation