Skip to content

Commit 3893c72

Browse files
xDaizuwouterj
authored andcommitted
Added escaping tip
Added a tip under the "Generating URLs from a Template" section to remind users of proper escaping if they are generating routes in a JS context
1 parent 5dfccb9 commit 3893c72

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

book/routing.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,18 @@ a template helper function:
15531553
Read this blog post.
15541554
</a>
15551555

1556+
.. tip::
1557+
1558+
If you are generating the route inside a script tag, you might need to properly escape it for Javascript
1559+
1560+
.. code-block:: javascript
1561+
1562+
<script>
1563+
var route = "{{ path('blog_show', {'slug': 'my-blog-post'})|escape('js') }}";
1564+
</script>
1565+
1566+
For more information, see the Twig documentation.
1567+
15561568
.. index::
15571569
single: Routing; Absolute URLs
15581570

0 commit comments

Comments
 (0)