mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-18 21:37:29 +00:00
Add more coding standard rules
This commit is contained in:
@@ -88,21 +88,34 @@ standards:
|
|||||||
[1, 2, 3]
|
[1, 2, 3]
|
||||||
{'name': 'Fabien'}
|
{'name': 'Fabien'}
|
||||||
|
|
||||||
|
* Do not put any spaces before and after ``=`` in macro argument declarations:
|
||||||
|
|
||||||
|
.. code-block:: twig
|
||||||
|
|
||||||
|
{% macro html_input(class="input") %}
|
||||||
|
|
||||||
|
* 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
|
* Use snake case for all variable names (provided by the application and
|
||||||
created in templates):
|
created in templates), function/filter/test names, argument names and named
|
||||||
|
arguments:
|
||||||
|
|
||||||
.. code-block:: twig
|
.. code-block:: twig
|
||||||
|
|
||||||
{% set name = 'Fabien' %}
|
{% set name = 'Fabien' %}
|
||||||
{% set first_name = 'Fabien' %}
|
{% set first_name = 'Fabien' %}
|
||||||
|
|
||||||
* Use snake case for all function/filter/test names:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ 'Fabien Potencier'|to_lower_case }}
|
{{ 'Fabien Potencier'|to_lower_case }}
|
||||||
{{ generate_random_number() }}
|
{{ 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
|
* Indent your code inside tags (use the same indentation as the one used for
|
||||||
the target language of the rendered template):
|
the target language of the rendered template):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user