Reputation: 1
I am trying to delete some part of my url (string) in twig, and I can not do it. The result is not that I expect:
"http://local.myurl.com/en/node/8"|replace("en/node/8", "")
I expect:
"http://local.myurl.com/"
And the result is:
"http://local.myurl.com/en/node/8"
Upvotes: 0
Views: 180
Reputation: 5782
You can try json format like this :
{% set url = "http://local.myurl.com/en/node/8" %}
{{ url|replace({"en/node/8" : ""}) }}
Upvotes: 2