简体   繁体   English

小胡子不遍历数组

[英]Mustache not iterating over array

I don't know what is going on (maybe it because it is the 12th consecutive hour working). 我不知道发生了什么事(也许是因为这是连续第12个小时工作)。 I always used this notation but now it just doesn't work (I already checked several time that the data is passed to this template I'm talking about). 我一直使用这种表示法,但现在却不起作用(我已经检查了好几次将数据传递到我正在谈论的模板中)。 Data is not iterated and the result is empty. 数据未迭代,结果为空。

Mustache code: 小胡子代码:

{{#ad}} 
   setInput("{{key}}", "{{value}}");
{{/ad}}

I tried also: 我也尝试过:

{{#ad}} 
   setInput("{{key}}", "{{value}}");
{{/ad}}

The data passed is the following: 传递的数据如下:

Array
(
[ad] => Array
    (
        [0] => Array
            (
                [key] => id
                [value] => 1
            )

        [1] => Array
            (
                [key] => created_on
                [value] => 1371464401
            )

        [2] => Array
            (
                [key] => updated_on
                [value] => 
            )

        [3] => Array
            (
                [key] => dealer_id
                [value] => 1
            )

     ) 
)

Solved: be careful to not pass hashes instead of "plain" arrays!! 解决:小心不要通过散列而不是“普通”数组! Even if it seemed to be a common array because of the indexing (0 => "a", 1 => "b") it was actually an hash! 即使由于索引(0 =>“ a”,1 =>“ b”)似乎是一个通用数组,它实际上也是一个哈希! So just return the malicious data within an array_values($data) to fix it! 因此,只需返回array_values($ data)中的恶意数据即可对其进行修复!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM