1

I've a plain text field, where I've added few text in wrapped in tag. I've tried to get the processed html text in the twig by using

   {{ content.field_front_page_description|field_value }}
    {% set text = content.field_front_page_description|field_value %}
      {% set build = {
      '#type':   'processed_text',
      '#text':    text|render,
      '#format': 'full_html',
      } %}
      {{ kint(build) }}
      {{ build }}

But it is returning an array with not processed text. How do I do that

  • Not really sure what you mean by processed html. Is this a twig file of a node, page or ??? In other words, what is the name of your twig file? – No Sssweat Jan 11 '17 at 5:27
  • Are you trying to build a render array and render it? What exactly are you trying to do? – Jaypan Jan 11 '17 at 5:38
  • @NoSssweat It is a twig file for a node. I have a plain text field, and I've few tags in it. I'm trying to get the processed text form that. – Fazeela Abu Zohra Jan 11 '17 at 5:41
  • @Jaypan I'm trying to process the HTML of the field. i'm not trying to build a render array. I just want to know how to apply checkmarkup in twig. – Fazeela Abu Zohra Jan 11 '17 at 5:42
0

Edited Code -

{% set build = {
      '#type':   'processed_text',
      '#text':    content.field_front_page_description.value,
      '#format': 'full_html',
} %}
      {{ kint(build) }}
      {{ build }}

Or,

{% set build = {
      '#type':   'processed_text',
      '#text':    node.field_front_page_description.value,
      '#format': 'full_html',
} %}
      {{ kint(build) }}
      {{ build }}
  • It didn't work, see my above code what I've done – Fazeela Abu Zohra Jan 11 '17 at 6:01
  • what is your field name? and what is field_value in your code? – Ashish Deynap Jan 11 '17 at 6:13
  • To get the field value only I've used a module called twig_field_value. So by giving content.field_front_page_description|field_value, it will only give the value. not the label of the field – Fazeela Abu Zohra Jan 11 '17 at 6:39
  • try my edited code only and see if it reflects changes – Ashish Deynap Jan 11 '17 at 7:43
  • It is not working – Fazeela Abu Zohra Jan 11 '17 at 8:39

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.