Change all foreach loops in Soy templates to use the for loop syntax

This also updates to a newer version of Closure Rules and fixes a protobuf dep
compile issue.

Full description of the change:

Soy supports 2 kinds of loops:
* foreach- for iterating over items in a collection, e.g.
  {foreach $item in $list}...{/foreach}
* for - for indexed iteration, e.g. {for $i in range(0, 10)}...{/for}

The reason Soy has two different loops is an accident of history; Soy didn’t use
to have a proper grammar for expressions and so the alternate ‘for...range’
syntax was added to make it possible to write indexed loops.  As the grammar has
improved having the two syntaxes is no longer necessary and so we are
eliminating one of them.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182843207
This commit is contained in:
mcilwain 2018-01-22 15:07:04 -08:00 committed by jianglai
parent 81dc2bbbc3
commit b5fb62c984
23 changed files with 105 additions and 106 deletions

View file

@ -30,7 +30,7 @@
<div class="{css('set')}">
<h1>Contact settings</h1>
<table>
{foreach $type in $possibleTypesLookup}
{for $type in $possibleTypesLookup}
{if isNonnull($contactsByType[$type[0]])}
<tr class="{css('kd-settings-pane-section')}">
<td>
@ -40,7 +40,7 @@
</td>
<td id="{$type[0]}-contacts"
class="{css('info')} {css('summary')} {css('domain-registrar-contacts')}">
{foreach $c in $contactsByType[$type[0]]}
{for $c in $contactsByType[$type[0]]}
{call .contactInfoCompact}
{param namePrefix: 'contacts[' + index($c) + '].' /}
{param name: $c['name'] /}
@ -53,10 +53,10 @@
{param faxNumber: $c['faxNumber'] /}
{/call}
{if (index($c) + 1) % 3 == 0}<br>{/if}
{/foreach}
{/for}
</td>
{/if}
{/foreach}
{/for}
</table>
</div>
{/template}
@ -185,11 +185,11 @@
<label class="{css('setting-label')}">Contact type</label>
<td class="{css('setting')}">
<div class="{css('setting-item-list')}">
{foreach $type in $possibleTypesLookup}
{for $type in $possibleTypesLookup}
{if $actualTypesLookup[$type[0]]}
<div>{$type[1]} contact</div>
{/if}
{/foreach}
{/for}
</div>
</td>
<tr><td colspan="2"><hr></tr>
@ -301,7 +301,7 @@
{@param namePrefix: string}
{@param actualTypesLookup: map<string, bool>}
{@param possibleTypesLookup: list<list<string>>}
{foreach $type in $possibleTypesLookup}
{for $type in $possibleTypesLookup}
{let $name: $namePrefix + 'type.' + $type[0] /}
{let $checked: $actualTypesLookup[$type[0]] /}
<div class="{css('checkbox-with-label')}">
@ -314,7 +314,7 @@
<span class="{css('description')}">{$type[2]}</span>
</label>
</div>
{/foreach}
{/for}
{/template}