Last active
December 6, 2016 21:32
-
-
Save MacDada/d677277d4d184541f0fdfb17a38ad1de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# what is the proper way to escape var in url path in html in twig? #} | |
{# method A #} | |
<a href="/foo/{{ bar }}">Link</a> | |
{# method B #} | |
<a href="/foo/{{ bar|e('url') }}">Link</a> | |
{# method C #} | |
<a href="/foo/{{ bar|url_encode }}">Link</a> | |
{# method D #} | |
<a href="/foo/{{ bar|url_encode(true) }}">Link</a> | |
{# other? #} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A
doesn't escape for urlB
andC
both userawurlencode()
B
wins as it does the job and is semantically superior