Skip to content

Commit 606b730

Browse files
committed
minor #6633 Added escaping tip (xDaizu)
This PR was submitted for the 3.1 branch but it was merged into the 2.7 branch instead (closes #6633). Discussion ---------- 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 Commits ------- 3893c72 Added escaping tip
2 parents 5dfccb9 + 3893c72 commit 606b730

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)