Skip to content
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

Add more coding standard rules #4474

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from
Open
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
23 changes: 18 additions & 5 deletions doc/coding_standards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,34 @@ standards:
[1, 2, 3]
{'name': 'Fabien'}
* Use snake case for all variable names (provided by the application and
created in templates):
* Do not put any spaces before and after ``=`` in macro argument declarations:

.. code-block:: twig
{% set name = 'Fabien' %}
{% set first_name = 'Fabien' %}
{% macro html_input(class="input") %}
* Use snake case for all function/filter/test names:
* Put exactly one space after the ``:`` sign in macro argument declarations:

.. code-block:: twig
{% macro html_input(class: "input") %}
* Use snake case for all variable names (provided by the application and
created in templates), function/filter/test names, argument names and named
arguments:

.. code-block:: twig
{% set name = 'Fabien' %}
{% set first_name = 'Fabien' %}
{{ 'Fabien Potencier'|to_lower_case }}
{{ generate_random_number() }}
{% macro html_input(class_name) %}
{{ html_input(class_name: 'pwd') }}
* Indent your code inside tags (use the same indentation as the one used for
the target language of the rendered template):

Expand Down
Loading