@@ -20,77 +20,77 @@ Functions
20
20
.. versionadded :: 2.4
21
21
The ``expression `` function was introduced in Symfony 2.4.
22
22
23
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
24
- | Function Syntax | Usage |
25
- +=======================================================+============================================================================================+
26
- | ``render(uri, options = {}) `` | This will render the fragment for the given controller or URL |
27
- | ``render(controller('B:C:a', {params})) `` | For more information, see :ref: `templating-embedding-controller `. |
28
- | ``render(path('route', {params})) `` | |
29
- | ``render(url('route', {params})) `` | |
30
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
31
- | ``render_esi(controller('B:C:a', {params})) `` | This will generate an ESI tag when possible or fallback to the ``render `` |
32
- | ``render_esi(url('route', {params})) `` | behavior otherwise. For more information, see :ref: `templating-embedding-controller `. |
33
- | ``render_esi(path('route', {params})) `` | |
34
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
35
- | ``render_hinclude(controller(...)) `` | This will generates an Hinclude tag for the given controller or URL. |
36
- | ``render_hinclude(url('route', {params})) `` | For more information, see :ref: `templating-embedding-controller `. |
37
- | ``render_hinclude(path('route', {params})) `` | |
38
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
39
- | ``controller(attributes = {}, query = {}) `` | Used along with the ``render `` tag to refer to the controller that you want to render. |
40
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
41
- | ``asset(path, packageName = null, absolute = false) `` | Get the public path of the asset, more information in |
42
- | | ":ref: `book-templating-assets `". |
43
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
44
- | ``asset_version(packageName = null) `` | Get the current version of the package, more information in |
45
- | | ":ref: `book-templating-assets `". |
46
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
47
- | ``form(view, variables = {}) `` | This will render the HTML of a complete form, more information in |
48
- | | in :ref: `the Twig Form reference<reference-forms-twig-form> `. |
49
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
50
- | ``form_start(view, variables = {}) `` | This will render the HTML start tag of a form, more information in |
51
- | | in :ref: `the Twig Form reference<reference-forms-twig-start> `. |
52
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
53
- | ``form_end(view, variables = {}) `` | This will render the HTML end tag of a form together with all fields that |
54
- | | have not been rendered yet, more information |
55
- | | in :ref: `the Twig Form reference<reference-forms-twig-end> `. |
56
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
57
- | ``form_enctype(view) `` | This will render the required ``enctype="multipart/form-data" `` attribute |
58
- | | if the form contains at least one file upload field, more information in |
59
- | | in :ref: `the Twig Form reference <reference-forms-twig-enctype >`. |
60
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
61
- | ``form_widget(view, variables = {}) `` | This will render a complete form or a specific HTML widget of a field, |
62
- | | more information in :ref: `the Twig Form reference <reference-forms-twig-widget >`. |
63
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
64
- | ``form_errors(view) `` | This will render any errors for the given field or the "global" errors, |
65
- | | more information in :ref: `the Twig Form reference <reference-forms-twig-errors >`. |
66
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
67
- | ``form_label(view, label = null, variables = {}) `` | This will render the label for the given field, more information in |
68
- | | :ref: `the Twig Form reference <reference-forms-twig-label >`. |
69
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
70
- | ``form_row(view, variables = {}) `` | This will render the row (the field's label, errors and widget) of the given |
71
- | | field, more information in :ref: `the Twig Form reference <reference-forms-twig-row >`. |
72
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
73
- | ``form_rest(view, variables = {}) `` | This will render all fields that have not yet been rendered, more |
74
- | | information in :ref: `the Twig Form reference <reference-forms-twig-rest >`. |
75
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
76
- | ``csrf_token(intention) `` | This will render a CSRF token. Use this function if you want CSRF protection without |
77
- | | creating a form |
78
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
79
- | ``is_granted(role, object = null, field = null) `` | This will return ``true `` if the current user has the required role, more |
80
- | | information in ":ref: `book-security-template `" |
81
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
82
- | ``logout_path(key) `` | This will generate the relative logout URL for the given firewall |
83
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
84
- | ``logout_url(key) `` | Equal to ``logout_path(...) `` but this will generate an absolute URL |
85
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
86
- | ``path(name, parameters = {}) `` | Get a relative URL for the given route, more information in |
87
- | | ":ref: `book-templating-pages `". |
88
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
89
- | ``url(name, parameters = {}) `` | Equal to ``path(...) `` but it generates an absolute URL |
90
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
91
- | ``expression(expression) `` | Creates an :class: `Symfony\\ Component\\ ExpressionLanguage\\ Expression ` in Twig. See |
92
- | | ":ref: `Template Expressions <book-security-template-expression >`". |
93
- +-------------------------------------------------------+--------------------------------------------------------------------------------------------+
23
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
24
+ | Function Syntax | Usage |
25
+ +======================================================================= +============================================================================================+
26
+ | ``render(uri, options = {}) `` | This will render the fragment for the given controller or URL |
27
+ | ``render(controller('B:C:a', {params})) `` | For more information, see :ref: `templating-embedding-controller `. |
28
+ | ``render(path('route', {params})) `` | |
29
+ | ``render(url('route', {params})) `` | |
30
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
31
+ | ``render_esi(controller('B:C:a', {params})) `` | This will generate an ESI tag when possible or fallback to the ``render `` |
32
+ | ``render_esi(url('route', {params})) `` | behavior otherwise. For more information, see :ref: `templating-embedding-controller `. |
33
+ | ``render_esi(path('route', {params})) `` | |
34
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
35
+ | ``render_hinclude(controller(...)) `` | This will generates an Hinclude tag for the given controller or URL. |
36
+ | ``render_hinclude(url('route', {params})) `` | For more information, see :ref: `templating-embedding-controller `. |
37
+ | ``render_hinclude(path('route', {params})) `` | |
38
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
39
+ | ``controller(attributes = {}, query = {}) `` | Used along with the ``render `` tag to refer to the controller that you want to render. |
40
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
41
+ | ``asset(path, packageName = null, absolute = false, version = null ) `` | Get the public path of the asset, more information in |
42
+ | | ":ref: `book-templating-assets `". |
43
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
44
+ | ``asset_version(packageName = null) `` | Get the current version of the package, more information in |
45
+ | | ":ref: `book-templating-assets `". |
46
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
47
+ | ``form(view, variables = {}) `` | This will render the HTML of a complete form, more information in |
48
+ | | in :ref: `the Twig Form reference<reference-forms-twig-form> `. |
49
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
50
+ | ``form_start(view, variables = {}) `` | This will render the HTML start tag of a form, more information in |
51
+ | | in :ref: `the Twig Form reference<reference-forms-twig-start> `. |
52
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
53
+ | ``form_end(view, variables = {}) `` | This will render the HTML end tag of a form together with all fields that |
54
+ | | have not been rendered yet, more information |
55
+ | | in :ref: `the Twig Form reference<reference-forms-twig-end> `. |
56
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
57
+ | ``form_enctype(view) `` | This will render the required ``enctype="multipart/form-data" `` attribute |
58
+ | | if the form contains at least one file upload field, more information in |
59
+ | | in :ref: `the Twig Form reference <reference-forms-twig-enctype >`. |
60
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
61
+ | ``form_widget(view, variables = {}) `` | This will render a complete form or a specific HTML widget of a field, |
62
+ | | more information in :ref: `the Twig Form reference <reference-forms-twig-widget >`. |
63
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
64
+ | ``form_errors(view) `` | This will render any errors for the given field or the "global" errors, |
65
+ | | more information in :ref: `the Twig Form reference <reference-forms-twig-errors >`. |
66
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
67
+ | ``form_label(view, label = null, variables = {}) `` | This will render the label for the given field, more information in |
68
+ | | :ref: `the Twig Form reference <reference-forms-twig-label >`. |
69
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
70
+ | ``form_row(view, variables = {}) `` | This will render the row (the field's label, errors and widget) of the given |
71
+ | | field, more information in :ref: `the Twig Form reference <reference-forms-twig-row >`. |
72
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
73
+ | ``form_rest(view, variables = {}) `` | This will render all fields that have not yet been rendered, more |
74
+ | | information in :ref: `the Twig Form reference <reference-forms-twig-rest >`. |
75
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
76
+ | ``csrf_token(intention) `` | This will render a CSRF token. Use this function if you want CSRF protection without |
77
+ | | creating a form |
78
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
79
+ | ``is_granted(role, object = null, field = null) `` | This will return ``true `` if the current user has the required role, more |
80
+ | | information in ":ref: `book-security-template `" |
81
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
82
+ | ``logout_path(key) `` | This will generate the relative logout URL for the given firewall |
83
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
84
+ | ``logout_url(key) `` | Equal to ``logout_path(...) `` but this will generate an absolute URL |
85
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
86
+ | ``path(name, parameters = {}) `` | Get a relative URL for the given route, more information in |
87
+ | | ":ref: `book-templating-pages `". |
88
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
89
+ | ``url(name, parameters = {}) `` | Equal to ``path(...) `` but it generates an absolute URL |
90
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
91
+ | ``expression(expression) `` | Creates an :class: `Symfony\\ Component\\ ExpressionLanguage\\ Expression ` in Twig. See |
92
+ | | ":ref: `Template Expressions <book-security-template-expression >`". |
93
+ +----------------------------------------------------------------------- +--------------------------------------------------------------------------------------------+
94
94
95
95
Filters
96
96
-------
0 commit comments