douyun8901 2017-01-18 10:55
浏览 13
已采纳

Mailjet - 模板中的多维数组

I'm using mailjet to send transactionnal e-mails with the APIv3.

The mail is sent correctly until i want to use the second level of a multidimensionnal array variable.

Here is the working bit of template :

{%for category in var:categories%}

{{category.title}} :

{% endfor %}

This shows the categories like Titre colonne 1 as expected.

But if i have this :

{%for category in var:categories%}

{{category.title}} :

{%for item in category.items%}

{% endfor %}

{% endfor %}

I receive this error from mailjet:

unknown node ## near ## 0px 0;">{%for item i ##

The array (value of variable categories) seems fine to me :

Array
(
    [0] => Array
        (
            [title] => Titre colonne 1
            [items] => Array
                (
                    [0] => Array
                        (
                            [title] => Item 1
                            [value] => 5
                        )

                    [1] => Array
                        (
                            [title] => Item 2
                            [value] => 10
                        )

                )

        )

    [1] => Array
        (
            [title] => Titre colonne 2
            [items] => Array
                (
                    [0] => Array
                        (
                            [title] => Item 3
                            [value] => 20
                        )

                )

        )

    [2] => Array
        (
            [title] => Titre colonne 3
            [items] => Array
                (
                    [0] => Array
                        (
                            [title] => Item 4
                            [value] => 40
                        )

                    [1] => Array
                        (
                            [title] => Item 5
                            [value] => 80
                        )

                    [2] => Array
                        (
                            [title] => Item 6
                            [value] => 160
                        )

                    [3] => Array
                        (
                            [title] => Item 7
                            [value] => 320
                        )

                )

        )

    [3] => Array
        (
            [title] => Titre colonne 4
            [items] => Array
                (
                )

        )

)

Does anyone sees where i did a mistake ?

  • 写回答

1条回答 默认 最新

  • dtqf81594 2017-01-18 11:27
    关注

    As stated on an other mailjet related question (https://stackoverflow.com/a/40014622/3005056), mailjet have trouble with multi-loop in there WYSIWYG.

    I've done it by adding HTML bloc and editing it.

    Now i have to find how to detect empty array...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 h3.6m 人类行为预测论文复现
  • ¥50 wordpress项目注册报失败刷新后其实是成功状态,请求排查原因
  • ¥20 linxu服务器僵尸进程不释放,代码如何修改?
  • ¥15 pycharm激活不成功
  • ¥40 如果update 一个列名为参数的value
  • ¥15 基于51单片机的水位检测系统设计中LCD1602一直不显示
  • ¥15 OCS2安装出现问题,请大家给点意见
  • ¥15 ros小车启动launch文件报错
  • ¥15 vs2015到期想登陆但是登陆不上
  • ¥15 IPQ5018制作烧录固件,boot运行失败(操作系统-linux)(相关搜索:操作系统)(相关搜索:操作系统)