【问题标题】:Outputting HTML in twig file using Bolt CMS使用 Bolt CMS 在树枝文件中输出 HTML
【发布时间】:2017-06-19 18:06:45
【问题描述】:

我在树枝中输出 html 时遇到问题。我正在使用 Bolt CMS 3.2

{% for item in menu %}
    <li class="list-inline {{ item.path == '/#' ? 'dropdown' }}">
        <a href="{{ item.path }}" >
            {% autoescape %}
                {% set caret = '<span class="caret"></span>' %}
                {{ (item.path == '/#') ? caret|raw : item.label }}
            {% endautoescape %}
        </a>
    </li>
{% endfor %}

但它一直将 html 输出为字符串。我使用了自动转义值,但它在这里什么都不做。我用错了吗?

【问题讨论】:

    标签: php twig bolt-cms


    【解决方案1】:

    试试这个:

    {% autoescape false %}
       {% set caret = '<span class="caret"></span>' %}
       {{ (item.path == '/#') ? caret|raw : item.label }}
    {% endautoescape %}
    

    来源:http://twig.sensiolabs.org/doc/2.x/tags/autoescape.html

    【讨论】:

      猜你喜欢
      • 2018-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-14
      • 2017-05-22
      • 1970-01-01
      • 2013-08-07
      • 2018-08-21
      相关资源
      最近更新 更多