From c96aefdf045ea021f1f6af3f8f18206f8d43e5a2 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 25 Nov 2024 17:24:14 +0100 Subject: [PATCH] Add more coding standard rules --- doc/coding_standards.rst | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/doc/coding_standards.rst b/doc/coding_standards.rst index d7daa08b506..dcae56da19d 100644 --- a/doc/coding_standards.rst +++ b/doc/coding_standards.rst @@ -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):