2

There are some variables like author_name in node.html.twig of Drupal 8. {{ author_name }} will print something like below:

 <div><span><span>Basic</span></span></div> 

I tried using codes like below: {{ author_name.0 }} plan to print: Basic or {{ author_name|field_value }} plan to print: Basic

Above codes NOT work. How can I achieve above result?

1 Answer 1

2

For most cases How do I get the raw field value in a twig template? will do. But since here according to node.html.twig

author_name: Themed author name field.

I believe you can get the unthemed author name by using {{ node.getOwner.getDisplayName }}

1
  • 1
    I have tested for this case (get the unthemed author name): {{ node.getOwner.getDisplayName }} works; {{ node.getOwner.getDisplayName.0 }} NOT work. Commented Dec 28, 2018 at 5:30

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.