xyu/jquery-tmpl-php — Issue #3: Issue with $data being lost after a nested {{each}}
Author: zenfoo
Created: 2011-12-15 22:03:42+00:00
State: open

Template:

Payment details

Delivery Address

${delivery_line_1}
${delivery_line_2}
${delivery_city}
${delivery_state} ${delivery_postcode}
${delivery_country}
[Change Address]

Billing Address

${billing_line_1}
${billing_line_2}
${billing_city}
${billing_state} ${delivery_postcode}
${billing_country}
[Change Address]

Product
Title
Quantity
Subtotal

{{each items}}

${this.name}
{{each this.item_options}}
${this.option_name}: ${this.option_value}
{{/each}}

${this.quantity}
${this.gross_price}

{{/each}}

Data:

array (
'change_address_url' => '/store/checkout?section=ship',
'delivery_line_1' => 'Test Street',
'delivery_line_2' => '',
'delivery_city' => 'Test',
'delivery_state' => 'Test',
'delivery_postcode' => '1234',
'delivery_country' => 'AUSTRALIA',
'billing_line_1' => 'Test Street',
'billing_line_2' => '',
'billing_city' => 'Test',
'billing_state' => 'Test',
'billing_postcode' => '1234',
'billing_country' => 'AUSTRALIA',
'items' =>
array (
0 =>
array (
'image' => '/images/10687_3024.jpg',
'quantity' => 2,
'gross_price' => 75.00,
'name' => 'Deluxe 03',
'item_options' =>
array (
0 =>
array (
'option_name' => 'Colour',
'option_value' => 'Black ',
),
1 =>
array (
'option_name' => 'Size',
'option_value' => 'XS',
),
),
),
),
)

The values ${this.quantity} and ${this.gross_price} are no longer available after the inner each loop and it's throwing and error. It seems like the "this" value gets lost after running the inner loop? It works fine if I move those two values before the inner {{each}} loop.