1

I don't know what is going on (maybe it because it is the 12th consecutive hour working). 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
            )

     ) 
)
Damiano Barbati
  • 3,356
  • 8
  • 39
  • 51

1 Answers1

2

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! So just return the malicious data within an array_values($data) to fix it!

Damiano Barbati
  • 3,356
  • 8
  • 39
  • 51
  • 2
    Mustache.php only treats zero-indexed arrays with consecutive keys as "arrays" instead of hashes. If you're missing any numbers in the list of keys, it'll treat it as a hash instead of a list. Most commonly this is caused by filtering the array, which removes elements but doesn't reset the keys. `array_values` or an ArrayIterator are the fix for that. – bobthecow Jun 17 '13 at 18:12