Twig如何在JSON内插

问题描述 投票:0回答:1

我目前正在尝试从字符串中删除Unicode特征。

    {% include 'components/accordion.twig' with {
      this: {
        id: program.slug,
        active: (loop.index == 1) ? true : false
      }
    } only %}
  {% endfor %}

基本上我想要达到的目标是

{% include 'components/accordion.twig' with {
          this: {
            id: "{{ programs.slug | convert_encoding('UTF-8', 'ISO-8859-1') }}"
            active: (loop.index == 1) ? true : false
          }
        } only %}
{% endfor %}

问题是programs.slug返回"aria-c-senior-citizens-rent-increase-exemption-%e2%80%8bscrie"我正在尝试删除%e2%80%8b,所以我通过"aria-c-senior-citizens-rent-increase-exemption-scrie"拥有了convert_encoding('UTF-8', 'ISO-8859-1')我该如何去做?

php wordpress
1个回答
0
投票

仅:

{% include 'components/accordion.twig' with {
  this: {
    id: program.slug | convert_encoding('UTF-8', 'ISO-8859-1'),
    active: (loop.index == 1) ? true : false
  }
} only %}

因为{{ }}等于echo

© www.soinside.com 2019 - 2024. All rights reserved.