From b69bbece46f6f12d29c327e02816d3f8bb85d320 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 24 Nov 2012 12:22:07 +0100 Subject: [PATCH 1/5] Removed 2.0 only functions --- reference/twig_reference.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index dd6aeac2d0a..b0b18e0429f 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -45,10 +45,6 @@ Functions | ``form_rest(form, variables = {})`` | This will render all fields that have not yet been rendered, more | | | information in :ref:`the Twig Form reference`. | +----------------------------------------------------+--------------------------------------------------------------------------------------------+ -| ``_form_is_choice_group(label)`` | This will return ``true`` if the label is a choice group. | -+----------------------------------------------------+--------------------------------------------------------------------------------------------+ -| ``_form_is_choice_selected(form, choice)`` | This will return ``true`` if the given choice is selected. | -+----------------------------------------------------+--------------------------------------------------------------------------------------------+ | ``is_granted(role, object = null, field = null)`` | This will return ``true`` if the current user has the required role, more | | | information in ":ref:`book-security-template`" | +----------------------------------------------------+--------------------------------------------------------------------------------------------+ From fcb1bce164040326fcdad18d79ba09ecfd76cea3 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 24 Nov 2012 12:36:46 +0100 Subject: [PATCH 2/5] Added new functions --- reference/twig_reference.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index b0b18e0429f..53ba970c5c2 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -45,9 +45,16 @@ Functions | ``form_rest(form, variables = {})`` | This will render all fields that have not yet been rendered, more | | | information in :ref:`the Twig Form reference`. | +----------------------------------------------------+--------------------------------------------------------------------------------------------+ +| ``csrf_token(intention)`` | This will render a CSRF token, use this function if you want CSRF protection without | +| | creating a form | ++----------------------------------------------------+--------------------------------------------------------------------------------------------+ | ``is_granted(role, object = null, field = null)`` | This will return ``true`` if the current user has the required role, more | | | information in ":ref:`book-security-template`" | +----------------------------------------------------+--------------------------------------------------------------------------------------------+ +| ``logout_path(key)`` | This will generate the relative logout URL for the given firewall | ++----------------------------------------------------+--------------------------------------------------------------------------------------------+ +| ``logout_url(key)`` | Equal to ``logout_path(...)`` but this will generate an absolute url | ++----------------------------------------------------+--------------------------------------------------------------------------------------------+ | ``path(name, parameters = {})`` | Get a relative url for the given route, more information in | | | ":ref:`book-templating-pages`". | +----------------------------------------------------+--------------------------------------------------------------------------------------------+ From 1e84ae9545d79d0e86b083e83fec9c65f74c8110 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 24 Nov 2012 12:44:00 +0100 Subject: [PATCH 3/5] Added Tests --- reference/twig_reference.rst | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index 53ba970c5c2..c200278c3d0 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -5,12 +5,12 @@ Symfony2 Twig Extensions ======================== Twig is the default template engine for Symfony2. By itself, it already contains -a lot of build-in functions, filters and tags (`http://twig.sensiolabs.org/documentation`_ +a lot of build-in functions, filters, tags and tests (`http://twig.sensiolabs.org/documentation`_ then scroll to the bottom). Symfony2 adds more custom extension on top of Twig to integrate some components into the Twig templates. Below is information about all the custom functions, -filters and tags that are added when using the Symfony2 Core Framework. +filters, tags and tests that are added when using the Symfony2 Core Framework. There may also be tags in bundles you use that aren't listed here. @@ -118,6 +118,15 @@ Tags | ``{% endtranschoice %}`` | | +---------------------------------------------------+-------------------------------------------------------------------+ +Tests +----- + ++---------------------------------------------------+------------------------------------------------------------------------------+ +| Test Syntax | Usage | ++===================================================+==============================================================================+ +| ``selectedchoice(choice, selectedValue)`` | This will return ``true`` if the choice is selected for the given form value | ++---------------------------------------------------+------------------------------------------------------------------------------+ + Global Variables ---------------- From d3cfc165ea645d03a10698c9340cb25965059ece Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 24 Nov 2012 12:50:26 +0100 Subject: [PATCH 4/5] Added humanize filter --- reference/twig_reference.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index c200278c3d0..756f700fb86 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -67,6 +67,9 @@ Filters +---------------------------------------------------------------------------------+-------------------------------------------------------------------+ | Filter Syntax | Usage | +=================================================================================+===================================================================+ +| ``text|humanize`` | Makes a technical name human readable (replaces underscores by | +| | spaces and capitalizes the string) | ++---------------------------------------------------------------------------------+-------------------------------------------------------------------+ | ``text|trans(arguments = {}, domain = 'messages', locale = null)`` | This will translate the text into the current language, more | | | information in :ref:`book-translation-twig`. | +---------------------------------------------------------------------------------+-------------------------------------------------------------------+ From ee494839558dc614355945256235c71d118db844 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 24 Nov 2012 12:54:32 +0100 Subject: [PATCH 5/5] Added versionadded blocks --- reference/twig_reference.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index 756f700fb86..970f0bee400 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -17,6 +17,9 @@ There may also be tags in bundles you use that aren't listed here. Functions --------- +.. versionadded:: 2.1 + The ``csrf_token``, ``logout_path`` and ``logout_url`` functions were added in Symfony2.1 + +----------------------------------------------------+--------------------------------------------------------------------------------------------+ | Function Syntax | Usage | +====================================================+============================================================================================+ @@ -64,6 +67,9 @@ Functions Filters ------- +.. versionadded:: 2.1 + The ``humanize`` filter was added in Symfony2.1 + +---------------------------------------------------------------------------------+-------------------------------------------------------------------+ | Filter Syntax | Usage | +=================================================================================+===================================================================+ @@ -124,6 +130,9 @@ Tags Tests ----- +.. versionadded:: 2.1 + The ``selectedchoice`` test was added in Symfony2.1 + +---------------------------------------------------+------------------------------------------------------------------------------+ | Test Syntax | Usage | +===================================================+==============================================================================+