@@ -114,6 +114,22 @@ asset
114
114
``packageName `` *(optional) *
115
115
**type **: ``string `` | ``null `` **default **: ``null ``
116
116
117
+ .. code-block :: yaml
118
+
119
+ # config/packages/framework.yaml
120
+ framework :
121
+ # ...
122
+ assets :
123
+ packages :
124
+ foo_package :
125
+ base_path : /avatars
126
+
127
+ .. code-block :: twig
128
+
129
+ {# the image lives at "public/avatars/avatar.png" #}
130
+ {{ asset(path = 'avatar.png', packageName = 'foo_package') }}
131
+ {# output: /avatars/avatar.png #}
132
+
117
133
Returns the public path of the given asset path (which can be a CSS file, a
118
134
JavaScript file, an image path, etc.). This function takes into account where
119
135
the application is installed (e.g. in case the project is accessed in a host
@@ -189,6 +205,30 @@ logout_path
189
205
Generates a relative logout URL for the given firewall. If no key is provided,
190
206
the URL is generated for the current firewall the user is logged into.
191
207
208
+ .. code-block :: yaml
209
+
210
+ # config/packages/security.yaml
211
+ security :
212
+ # ...
213
+
214
+ firewalls :
215
+ main :
216
+ # ...
217
+ logout :
218
+ path : ' /logout'
219
+ othername :
220
+ # ...
221
+ logout :
222
+ path : ' /other/logout'
223
+
224
+ .. code-block :: twig
225
+
226
+ {{ logout_path(key = 'main') }}
227
+ {# output: /logout #}
228
+
229
+ {{ logout_path(key = 'othername') }}
230
+ {# output: /other/logout #}
231
+
192
232
logout_url
193
233
~~~~~~~~~~
194
234
@@ -202,6 +242,30 @@ logout_url
202
242
Equal to the `logout_path `_ function, but it'll generate an absolute URL
203
243
instead of a relative one.
204
244
245
+ .. code-block :: yaml
246
+
247
+ # config/packages/security.yaml
248
+ security :
249
+ # ...
250
+
251
+ firewalls :
252
+ main :
253
+ # ...
254
+ logout :
255
+ path : ' /logout'
256
+ othername :
257
+ # ...
258
+ logout :
259
+ path : ' /other/logout'
260
+
261
+ .. code-block :: twig
262
+
263
+ {{ logout_url(key = 'main') }}
264
+ {# output: http://example.org/logout #}
265
+
266
+ {{ logout_url(key = 'othername') }}
267
+ {# output: http://example.org/other/logout #}
268
+
205
269
path
206
270
~~~~
207
271
@@ -219,6 +283,14 @@ path
219
283
Returns the relative URL (without the scheme and host) for the given route.
220
284
If ``relative `` is enabled, it'll create a path relative to the current path.
221
285
286
+ .. code-block :: twig
287
+
288
+ {{ path(name = 'app_blog', parameters = {page: 3}, relative = false) }}
289
+ {# output (depending on the route configuration): /blog/3 or /blog?page=3 #}
290
+
291
+ {{ path(name = 'app_blog', parameters = {page: 3}, relative = true) }}
292
+ {# output (depending on the route configuration): blog/3 or ?page=3 #}
293
+
222
294
.. seealso ::
223
295
224
296
Read more about :doc: `Symfony routing </routing >` and about
241
313
Returns the absolute URL (with scheme and host) for the given route. If
242
314
``schemeRelative `` is enabled, it'll create a scheme-relative URL.
243
315
316
+ .. code-block :: twig
317
+
318
+ {{ url(name = 'app_blog', parameters = {page: 3}, schemeRelative = false) }}
319
+ {# output (depending on the route configuration): http://example.org/blog/3
320
+ or http://example.org/blog?page=3 #}
321
+
322
+ {{ url(name = 'app_blog', parameters = {page: 3}, schemeRelative = true) }}
323
+ {# output (depending on the route configuration): //example.org/blog/3
324
+ or //example.org/blog?page=3 #}
325
+
244
326
.. seealso ::
245
327
246
328
Read more about :doc: `Symfony routing </routing >` and about
@@ -292,6 +374,11 @@ expression
292
374
Creates an :class: `Symfony\\ Component\\ ExpressionLanguage\\ Expression ` related
293
375
to the :doc: `ExpressionLanguage component </components/expression_language >`.
294
376
377
+ .. code-block :: twig
378
+
379
+ {{ expression(1 + 2) }}
380
+ {# output: 3 #}
381
+
295
382
impersonation_exit_path
296
383
~~~~~~~~~~~~~~~~~~~~~~~
297
384
@@ -577,6 +664,11 @@ file_link
577
664
Generates a link to the provided file and line number using
578
665
a preconfigured scheme.
579
666
667
+ .. code-block :: twig
668
+
669
+ {{ 'path/to/file/file.txt'|file_link(line = 3) }}
670
+ {# output: file://path/to/file/file.txt#L3 #}
671
+
580
672
file_relative
581
673
~~~~~~~~~~~~~
582
674
0 commit comments