mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-31 04:27:00 +00:00
Enhancement: Use no_explicit_use_of_code_block_php rule
This commit is contained in:
@@ -17,6 +17,7 @@ rules:
|
||||
no_blank_line_after_filepath_in_xml_code_block: ~
|
||||
no_blank_line_after_filepath_in_yaml_code_block: ~
|
||||
no_composer_req: ~
|
||||
no_explicit_use_of_code_block_php: ~
|
||||
no_inheritdoc: ~
|
||||
no_namespace_after_use_statements: ~
|
||||
no_php_open_tag_in_code_block_php_directive: ~
|
||||
|
||||
@@ -53,9 +53,7 @@ date, use a ternary operator:
|
||||
If no format is provided, Twig will use the default one: ``F j, Y H:i``. This
|
||||
default can be changed by calling the ``setDateFormat()`` method on the
|
||||
``core`` extension instance. The first argument is the default format for
|
||||
dates and the second one is the default format for date intervals:
|
||||
|
||||
.. code-block:: php
|
||||
dates and the second one is the default format for date intervals::
|
||||
|
||||
$twig = new \Twig\Environment($loader);
|
||||
$twig->getExtension('\Twig\Extension\CoreExtension')->setDateFormat('d/m/Y', '%d days');
|
||||
@@ -81,9 +79,7 @@ timezone, pass ``false`` as the timezone value:
|
||||
|
||||
{{ post.published_at|date("m/d/Y", false) }}
|
||||
|
||||
The default timezone can also be set globally by calling ``setTimezone()``:
|
||||
|
||||
.. code-block:: php
|
||||
The default timezone can also be set globally by calling ``setTimezone()``::
|
||||
|
||||
$twig = new \Twig\Environment($loader);
|
||||
$twig->getExtension('\Twig\Extension\CoreExtension')->setTimezone('Europe/Paris');
|
||||
|
||||
@@ -104,9 +104,7 @@ Custom Escapers
|
||||
|
||||
You can define custom escapers by calling the ``setEscaper()`` method on the
|
||||
``core`` extension instance. The first argument is the escaper name (to be
|
||||
used in the ``escape`` call) and the second one must be a valid PHP callable:
|
||||
|
||||
.. code-block:: php
|
||||
used in the ``escape`` call) and the second one must be a valid PHP callable::
|
||||
|
||||
$twig = new \Twig\Environment($loader);
|
||||
$twig->getExtension('\Twig\Extension\CoreExtension')->setEscaper('csv', 'csv_escaper');
|
||||
|
||||
@@ -34,9 +34,7 @@ options of:
|
||||
* ``.`` as the decimal point.
|
||||
* ``,`` as the thousands separator.
|
||||
|
||||
These defaults can be changed through the core extension:
|
||||
|
||||
.. code-block:: php
|
||||
These defaults can be changed through the core extension::
|
||||
|
||||
$twig = new \Twig\Environment($loader);
|
||||
$twig->getExtension('\Twig\Extension\CoreExtension')->setNumberFormat(3, '.', ',');
|
||||
|
||||
@@ -38,9 +38,7 @@ If no argument is passed, the function returns the current date:
|
||||
.. note::
|
||||
|
||||
You can set the default timezone globally by calling ``setTimezone()`` on
|
||||
the ``core`` extension instance:
|
||||
|
||||
.. code-block:: php
|
||||
the ``core`` extension instance::
|
||||
|
||||
$twig = new \Twig\Environment($loader);
|
||||
$twig->getExtension('\Twig\Extension\CoreExtension')->setTimezone('Europe/Paris');
|
||||
|
||||
+1
-3
@@ -46,9 +46,7 @@ The recommended way to install Twig is via Composer:
|
||||
Basic API Usage
|
||||
---------------
|
||||
|
||||
This section gives you a brief introduction to the PHP API for Twig.
|
||||
|
||||
.. code-block:: php
|
||||
This section gives you a brief introduction to the PHP API for Twig::
|
||||
|
||||
require_once '/path/to/vendor/autoload.php';
|
||||
|
||||
|
||||
+1
-3
@@ -559,9 +559,7 @@ include in your templates:
|
||||
$interpolateProvider.startSymbol('{[').endSymbol(']}');
|
||||
});
|
||||
|
||||
* For Twig, change the delimiters via the ``tag_variable`` Lexer option:
|
||||
|
||||
.. code-block:: php
|
||||
* For Twig, change the delimiters via the ``tag_variable`` Lexer option::
|
||||
|
||||
$env->setLexer(new \Twig\Lexer($env, [
|
||||
'tag_variable' => ['{[', ']}'],
|
||||
|
||||
Reference in New Issue
Block a user