rawurlencode in Twig
{% set my_name = "Pro Tip" %}
{{ my_name|url_encode }}
Shows: Pro+Tip
{{ my_name|url_encode(true) }}
Shows: Pro%20Tip
Written by Roger Thomas
Related protips
2 Responses
What's the "true" actually referring to here? (I would have thought that the default behaviour anyway)
over 1 year ago
·
It's the type of encoding used on the characters. Its the difference between urlencode() and rawurlencode() in PHP. rawurlencode formats strings according to RFC 3986.
Unfortunately twig doesn't seem to care about using logic. Plus the fact that even the twig documentation fails to tell us that url_encode can even take the true param.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Related Tags
#php
#symfony
#template
#templating
#rawurlencode
#url_encode
#urlencode
#twig function
#twig
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#