Skip to content

Commit

Permalink
minor #4474 Add more coding standard rules (fabpot)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.x branch.

Discussion
----------

Add more coding standard rules

Commits
-------

c96aefd Add more coding standard rules
  • Loading branch information
fabpot committed Nov 30, 2024
2 parents 101d181 + c96aefd commit f0066c8
Showing 1 changed file with 18 additions and 5 deletions.
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

0 comments on commit f0066c8

Please sign in to comment.