AngelDoReMi / closure-templates

Automatically exported from code.google.com/p/closure-templates
Apache License 2.0
0 stars 0 forks source link

no way to define temporary local variable in a function #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. We need to compare 1 array element to the previous element in a loop
2. if certain data has changed, eg: date
3. then perform an action, ie: output some HTML

What is the expected output? What do you see instead?
I would hope to see a way to define(and update) a temporary local variable
that can be compared to the current loop element
eg: 
{define myVar $event.date}
so if can be later used...
{if($myVar == $newEvent.date)}...{/if}

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by goo...@technicalmagic.co.uk on 12 Nov 2009 at 10:41

GoogleCodeExporter commented 8 years ago
You can achieve comparing consecutive array elements by using the 'for' loop:

{for $i in range(length($events) - 1)}
  {if $events[$i].date == $events[$i + 1].date}
    ...
  {/if}
{/for}

Original comment by kai.hu...@gmail.com on 13 Nov 2009 at 11:07

GoogleCodeExporter commented 8 years ago
Closing as WontFix since:
(a) the design of Closure Templates specifically disallows this in template 
code.
(b) in this issue's comments, we provided a different way to achieve the 
desired result.

Original comment by kai.hu...@gmail.com on 14 Dec 2009 at 10:23