I'm new in a Drupal 8 and using Devel kint() function for debugging. In my twig template menu--main.html.twig, I have looped for the menu items like this:-

{% for item in items %} {{kint(item.url)}}

The output like this:-

enter image description here

What I should write to print the URI, I've tried {{item.url.uri}} but not working

  • 1
    Do you try {{item.url.getUri}} ? – MrD Oct 10 '17 at 9:32
  • Just guessing, {% if item.url.isExternal() %}foo{% endif %} – user21641 Oct 10 '17 at 10:33
  • Him want get uri of url not external :D – MrD Oct 10 '17 at 10:47
  • @MrD It's working fine, Thanks so much. but how I know that I have to write getUri to render it – Mohamed Osama Gbril Oct 10 '17 at 12:44

You can try {{item.url.getUri}}.

You can change to tab Available methods to see other method. Example isExternal. :D

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.