Drupal 8 不显示 html 标签作为字段值

Drupal 8 don't display html tags as value of field

在mytheme.theme中我找到值:

$programmes = [];
$view = Views::getView('participating_programmes');
$view->execute();
foreach($view->result as $row){
    $nid = $row->_entity->get('nid')->getValue();
    $nid = $nid[0]['value'];
$text = $row->_entity->get('field_copy_text')->getValue();    
$programmes[$nid]['text'] = $text[0]['value'];

然后我将它输出到我的树枝中:

{{ programme.text }}

我得到了包含所有标签的完整 html:

<p>This is the <strong>copy </strong>text for the Music subject.</p> <p>This is a <em>second </em>line with a break.</p>

我不想去掉标签。我想将其显示为带有中断和样式的 html 输出。

您需要更改您的 twig 文件以将 HTML 输出为:

{{ programme.text|raw }}