From 0a25c1732fbc20e70e97abbc5b10f313e511590a Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 4 Jul 2017 16:40:39 +0200 Subject: [PATCH 1/3] Added docs for "date" and "number_format" Twig options --- reference/configuration/twig.rst | 117 ++++++++++++++++++++++++++----- 1 file changed, 100 insertions(+), 17 deletions(-) diff --git a/reference/configuration/twig.rst b/reference/configuration/twig.rst index 79fcd4161af..efb8e275532 100644 --- a/reference/configuration/twig.rst +++ b/reference/configuration/twig.rst @@ -53,6 +53,16 @@ TwigBundle Configuration ("twig") paths: '%kernel.root_dir%/../vendor/acme/foo-bar/templates': foo_bar + # The following were added in Symfony 2.7. + date: + format: d.m.Y, H:i:s + interval_format: '%%d days' + timezone: Asia/Tokyo + number_format: + decimals: 2 + decimal_point: ',' + thousands_separator: '.' + .. code-block:: xml @@ -92,23 +102,33 @@ TwigBundle Configuration ("twig") 'form_themes' => array( 'form_div_layout.html.twig', // Default 'MyBundle::form.html.twig', - ), - 'globals' => array( - 'foo' => '@bar', - 'pi' => 3.14, - ), - 'auto_reload' => '%kernel.debug%', - 'autoescape' => 'name', - 'base_template_class' => 'Twig_Template', - 'cache' => '%kernel.cache_dir%/twig', - 'charset' => '%kernel.charset%', - 'debug' => '%kernel.debug%', - 'strict_variables' => false, - 'exception_controller' => 'AcmeFooBundle:Exception:showException', - 'optimizations' => true, - 'paths' => array( - '%kernel.root_dir%/../vendor/acme/foo-bar/templates' => 'foo_bar', - ), + ), + 'globals' => array( + 'foo' => '@bar', + 'pi' => 3.14, + ), + 'auto_reload' => '%kernel.debug%', + 'autoescape' => 'name', + 'base_template_class' => 'Twig_Template', + 'cache' => '%kernel.cache_dir%/twig', + 'charset' => '%kernel.charset%', + 'debug' => '%kernel.debug%', + 'strict_variables' => false, + 'exception_controller' => 'AcmeFooBundle:Exception:showException', + 'optimizations' => true, + 'paths' => array( + '%kernel.root_dir%/../vendor/acme/foo-bar/templates' => 'foo_bar', + ), + 'date' => array( + 'format' => 'd.m.Y, H:i:s', + 'interval_format' => '%%d days', + 'timezone' => 'Asia/Tokyo', + ), + 'number_format' => array( + 'decimals' => 2, + 'decimal_point' => ',', + 'thousands_separator' => '.', + ), )); .. caution:: @@ -208,6 +228,37 @@ charset The charset used by the template files. In the Symfony Standard edition this defaults to the ``UTF-8`` charset. +date +~~~~ + +These options define the default values used by the ``date`` filter to format +date and time values. They are useful to avoid passing the same arguments on +every ``date`` filter call. + +format +...... + +**type**: ``string`` **default**: ``F j, Y H:i`` + +The format used by the ``date`` filter to display values when no specific format +is passed as argument. + +internal_format +............... + +**type**: ``string`` **default**: ``%d days`` + +The format used by the ``date`` filter to display ``DateInterval`` instances +when no specific format is passed as argument. + +timezone +........ + +**type**: ``string`` **default**: (the value returned by ``date_default_timezone_get()``) + +The timezone used when formatting date values with the ``date`` filter and no +specific timezone is passed as argument. + debug ~~~~~ @@ -232,6 +283,38 @@ option is advanced. If you need to customize an error page you should use the previous link. If you need to perform some behavior on an exception, you should add a listener to the ``kernel.exception`` event (see :ref:`dic-tags-kernel-event-listener`). +number_format +~~~~~~~~~~~~~ + +These options define the default values used by the ``number_format`` filter to +format numeric values. They are useful to avoid passing the same arguments on +every ``number_format`` filter call. + +decimals +........ + +**type**: ``integer`` **default**: ``0`` + +The number of decimals used to format numeric values when no specific number is +passed as argument to the ``number_format`` filter. + +decimal_point +............. + +**type**: ``string`` **default**: ``.`` + +The character used to separate the decimals from the integer part of numeric +values when no specific character is passed as argument to the ``number_format`` +filter. + +thousands_separator +................... + +**type**: ``string`` **default**: ``,`` + +The character used to separate every group of thousands in numeric values when +no specific character is passed as argument to the ``number_format`` filter. + optimizations ~~~~~~~~~~~~~ From 11e245b21ee4b97d4a0d7868d64020664ba6fc97 Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Sat, 29 Jul 2017 16:22:59 +0200 Subject: [PATCH 2/3] Updated xml config --- reference/configuration/twig.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/reference/configuration/twig.rst b/reference/configuration/twig.rst index efb8e275532..ad6cd8fca33 100644 --- a/reference/configuration/twig.rst +++ b/reference/configuration/twig.rst @@ -89,6 +89,10 @@ TwigBundle Configuration ("twig") 3.14 + + + + AcmeFooBundle:Exception:showException %kernel.root_dir%/../vendor/acme/foo-bar/templates From cbbfe44af3b882d4b55a24747cfaf7bedb450ae2 Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Sat, 29 Jul 2017 16:25:09 +0200 Subject: [PATCH 3/3] Removed an extra line --- reference/configuration/twig.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/reference/configuration/twig.rst b/reference/configuration/twig.rst index 4d400c7238e..954b6ad1d46 100644 --- a/reference/configuration/twig.rst +++ b/reference/configuration/twig.rst @@ -90,7 +90,6 @@ TwigBundle Configuration ("twig") 3.14 - pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy