如何渲染字符串html

发布于 2025-01-13 03:50:12 字数 539 浏览 1 评论 0原文

我有自定义块,其中包含以下代码。

 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;

这返回到 twig 文件,例如

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

我在浏览器上以 html 形式输出,当我检查它时,我看到 html 用双引号引起来。我必须在浏览器上将其呈现为视频。我在这里做错了什么

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绿光 2025-01-20 03:50:12

尝试这样的事情

{!! $描述!!}

Try Something Like This

{!! $description !!}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文