0

I have installed and configured Shortcode in a D8 project. However, when I try to use a short code like [column] or [button], it gets rendered as is in the node view page.

I have used a block panel in the node view page. And the in the block template I have rendered the body field like {{ content['#node'].body[0].value|raw }}.

However, I have noticed, that if I render the content as a whole like {{ content }}, the short codes gets rendered properly as intended.

What am I doing wrong?

1 Answer 1

1

You shouldn’t render field values like that. You should be doing it as {{ content }} or {{ content.field_name }}.

4
  • But I am not getting a {{ content.field_name }} in the twig file. Remember, its not a node.html.twig but a block--entity-view--node--article.html.twig Commented May 8, 2018 at 6:49
  • To add, what I am trying to do is render the body field that contains shortcode. The shortcodes are rendered as is in the page. Commented May 8, 2018 at 12:30
  • Then it’s {{ block_content.field_name }}
    – Kevin
    Commented May 8, 2018 at 12:54
  • Could'nt get the block_content variable also. I instead created a separate block to render the field and in turn rendered that block inside this twig template. Commented May 9, 2018 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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