【问题标题】:Drupal 8 Twig removes all style tags from variable during renderingDrupal 8 Twig 在渲染期间从变量中删除所有样式标签
【发布时间】:2017-04-06 10:32:56
【问题描述】:

如何保留在 preprocess_page 期间添加的变量的所有内容。

例如在 twig 文件中进行变量渲染时也需要添加样式标签。

【问题讨论】:

  • 请添加一些有问题的代码
  • 如果没有更多详细信息、代码、目的和上下文,我们无法为您提供帮助。更准确,会给你一个准确的答案
  • 根据我的要求用不同的解决方案回答。

标签: drupal twig


【解决方案1】:
class MaisexpertBlock extends BlockBase {
    public function build() {
        return array(
            //'#cache' => array('max-age' => 0),
            '#type' => 'inline_template',
            '#template' => '{{ somecontent | raw }}',
            '#context' => array('somecontent' => 'Your content with <html></html> code'),
        );
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-13
    • 1970-01-01
    • 1970-01-01
    • 2020-08-09
    • 1970-01-01
    • 1970-01-01
    • 2016-02-22
    • 2012-07-13
    相关资源
    最近更新 更多