-1

I have custom block which has following code.

 foreach ($video_result as $video){
    $title = $video->title;
    $video_body = $video->body_value; 
  }
  
 var_dump($video_body);

    $renderable = [
        '#theme' => 'video-block',
        '#title' => $title,
        '#description' => $video_body
      ];
      return $renderable;

And this return to twig file such as

<h6>Title {{ title }}</h6>
{{ description | raw}}

I get output as html on browser and when i inspect it i see html is wrap with double quotes. I have to render it as video on browser. What i am doing wrong here

Madhav
  • 1
  • 2
  • Why are you applying `htmlentities` to the variable `$video`? This will convert all HTML to HTML entities, e.g. `
    ` becomes `<div>`
    – DarkBee Mar 11 '22 at 06:36
  • Then please suggest me the right way to achieve my requirements. – Madhav Mar 11 '22 at 07:14
  • Don't apply `htmlentities`? – DarkBee Mar 11 '22 at 07:15
  • I have this value which i have to pass to twig file to render the video . How i pass that so that i get the value and render in twig file so that video start displaying on browser. – Madhav Mar 11 '22 at 07:22
  • Please do a `var_dump($video)`? – DarkBee Mar 11 '22 at 07:25
  • If i remove htmlentities $video is printing empty div `
    ` . I want whole video player code but it just printing empty div. var_dump is showing me string(541).
    – Madhav Mar 11 '22 at 08:05
  • Add the output of the var_dump as an [edit](https://stackoverflow.com/posts/71433680/edit) in your question – DarkBee Mar 11 '22 at 08:09
  • Done. If i do var_dump($video_body) . Then on browser video start playing and also getting string(541) before video " video playing on browser " and quotes end after video. – Madhav Mar 11 '22 at 08:25
  • At this point I can't [reproduce](https://twigfiddle.com/mlhs0a) this. Please update the code with how you actually are passing the variable from the controller to twig. The code above just shows that you return an array, also you suddenly changed `video` to `video_body`. If you are passing the exact array shown in the code then the variable `description` shouldn't even exist. – DarkBee Mar 11 '22 at 09:21

1 Answers1

-2

Try Something Like This

{!! $description !!}

Istiake
  • 41
  • 1
  • 7