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...

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

报告相同问题?

悬赏问题

  • ¥30 vb net 使用 sendMessage 如何输入鼠标坐标
  • ¥200 求能开发抖音自动回复卡片的软件
  • ¥15 关于freesurfer使用freeview可视化的问题
  • ¥100 谁能在荣耀自带系统MagicOS版本下,隐藏手机桌面图标?
  • ¥15 求SC-LIWC词典!
  • ¥20 有关esp8266连接阿里云
  • ¥15 C# 调用Bartender打印机打印
  • ¥15 我这个代码哪里有问题 acm 平台上显示错误 90%,我自己运行好像没什么问题
  • ¥50 C#编程中使用printDocument类实现文字排版打印问题
  • ¥15 找会编程的帅哥美女 可以用MATLAB里面的simulink编程,用Keil5编也可以。