How to get the rendered paragraph field of a node

by GiorgosK   Last Updated December 20, 2017 07:07 AM

I am trying to get the rendered field for an overriden REST export views display (json output)

a simplified version of what I have is this

$nid = 2;
$node = entity_load("node", $nid);
$paragraphs = $node->field_paragraphs->getValue();
$output = "";
foreach ( $paragraphs as $para ) {
    $p = \Drupal\paragraphs\Entity\Paragraph::load( $para['target_id'] );
    $output .= $p->field_text->value;

but the output is not really rendered (does not contain all wrapper divs and classes found when viewing the node

is there any way to get the rendered field ?

Related Questions

WYSIWYG editor on Paragraphs text field [Drupal 8]

Updated September 27, 2017 20:07 PM

Add custom field to specific paragraph field

Updated August 30, 2017 13:07 PM

Clone paragraphs field

Updated October 10, 2017 23:07 PM