我试图在我的产品页面(opencart v3)上输出产品的属性。
该属性称为“technicaldetails”,使用以下代码可以正常工作:
{% if attribute_groups %}
{% for attribute_group in attribute_groups %}
{% if attribute_group.name == 'technicaldetails' %}
{% for attribute in attribute_group.attribute %}
{{ attribute.text }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
Run Code Online (Sandbox Code Playgroud)
但是技术细节字段中存储了无样式的列表..这会输出完整的 html 而不是渲染列表。
我尝试过使用{{ attribute.text|e }}and{{ attribute.text|raw }}以及我能找到的许多其他替代方案..但每次都只是抛出 html 而不是渲染它..
在 php 中这曾经有效。
<?php echo html_entity_decode($attribute['text']); ?>
Run Code Online (Sandbox Code Playgroud)
那么我现在如何解码 html,因为我不能在 twig 中使用 php 并且 twig 中也没有 html_entity_decode :(
期待一些帮助:)
非常感激
谢谢。