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

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 2 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.

As of [1] or mvn release "2018-01-03" the two forms are actually aliases
for one another, so the only difference is the keyword ('for' vs
'foreach'), and while the foreach loop is more popular the 'for'
terminology is more standard so upstream recommends switching everything
to that.

[1] https://github.com/google/closure-templates/commit/4a7373333fee6c22784b48e29825b9cea3ffaae7

PiperOrigin-RevId: 180807358
Change-Id: I22fe13baffae5567d0e123395a62f2d837ea374c
diff --git a/resources/com/google/gitiles/templates/BlameDetail.soy b/resources/com/google/gitiles/templates/BlameDetail.soy
index 20c30de..f245c9c 100644
--- a/resources/com/google/gitiles/templates/BlameDetail.soy
+++ b/resources/com/google/gitiles/templates/BlameDetail.soy
@@ -45,7 +45,7 @@
   {call .blobHeader data="$data" /}
 
   <table class="Blame">
-    {foreach $line in $data.lines}
+    {for $line in $data.lines}
       {let $i: index($line) /}
       {let $region: $regions[$i] /}
       <tr class="Blame-region {$region.class}">
@@ -65,12 +65,12 @@
           <a class="u-monospace u-lineNum" href="#{$n}" name="{$n}">{$n}</a>
         </td>
         <td class="u-pre u-monospace Blame-lineContent">
-          {foreach $span in $line}
+          {for $span in $line}
             <span class="{$span.classes}">{$span.text}</span>
-          {/foreach}
+          {/for}
         </td>
       </tr>
-    {/foreach}
+    {/for}
   </table>
 {else}
   {call .header data="all" /}
diff --git a/resources/com/google/gitiles/templates/Common.soy b/resources/com/google/gitiles/templates/Common.soy
index f220c41..7b7c371 100644
--- a/resources/com/google/gitiles/templates/Common.soy
+++ b/resources/com/google/gitiles/templates/Common.soy
@@ -41,9 +41,9 @@
 
   <link rel="stylesheet" type="text/css" href="{gitiles.BASE_CSS_URL}">
   {if $css and length($css)}
-    {foreach $url in $css}
+    {for $url in $css}
       <link rel="stylesheet" type="text/css" href="{$url}">
-    {/foreach}
+    {/for}
   {/if}
   {delcall gitiles.customHeadTagPart variant="$customVariant ?: ''" /}
 
@@ -55,14 +55,14 @@
 
       {if $menuEntries and length($menuEntries)}
         <div class="Header-menu">
-        {foreach $entry in $menuEntries}
+        {for $entry in $menuEntries}
           {sp}
           {if $entry.url}
             <a class="Header-menuItem" href="{$entry.url}">{$entry.text}</a>
           {else}
             <span class="Header-menuItem Header-menuItem--noAction">{$entry.text}</span>
           {/if}
-        {/foreach}
+        {/for}
         {sp}
         </div>
       {/if}
@@ -73,14 +73,14 @@
     <div class="Container {if $containerClass}{$containerClass}{/if}">
       {if $breadcrumbs and length($breadcrumbs)}
         <div class="Breadcrumbs">
-          {foreach $entry in $breadcrumbs}
+          {for $entry in $breadcrumbs}
             {if not isFirst($entry)}{sp}/{sp}{/if}
             {if not isLast($entry)}
               <a class="Breadcrumbs-crumb" href="{$entry.url}">{$entry.text}</a>
             {else}
               <span class="Breadcrumbs-crumb">{$entry.text}</span>
             {/if}
-          {/foreach}
+          {/for}
         </div>
       {/if}
 {/template}
diff --git a/resources/com/google/gitiles/templates/DiffDetail.soy b/resources/com/google/gitiles/templates/DiffDetail.soy
index b3d723c..147c90f 100644
--- a/resources/com/google/gitiles/templates/DiffDetail.soy
+++ b/resources/com/google/gitiles/templates/DiffDetail.soy
@@ -48,14 +48,14 @@
 {template .diffHeader}
 <pre class="u-pre u-monospace Diff">
   <a name="F{$fileIndex}" class="Diff-fileIndex"></a>
-  {foreach $part in $firstParts}
+  {for $part in $firstParts}
     {if not isFirst($part)}{sp}{/if}
     {if $part.url}
       <a href="{$part.url}">{$part.text}</a>
     {else}
       {$part.text}
     {/if}
-  {/foreach}{\n}
+  {/for}{\n}
   {$rest}
 </pre>
 {/template}
diff --git a/resources/com/google/gitiles/templates/HostIndex.soy b/resources/com/google/gitiles/templates/HostIndex.soy
index bb62611..c1a3438 100644
--- a/resources/com/google/gitiles/templates/HostIndex.soy
+++ b/resources/com/google/gitiles/templates/HostIndex.soy
@@ -54,12 +54,12 @@
         {/msg}
       </span>
     </div>
-    {foreach $repo in $repositories}
+    {for $repo in $repositories}
       <a class="RepoList-item" href="{$repo.url}">
         <span class="RepoList-itemName">{$repo.name}</span>
         <span class="RepoList-itemDescription">{$repo.description}</span>
       </a>
-    {/foreach}
+    {/for}
   </div>
 {/if}
 
diff --git a/resources/com/google/gitiles/templates/LogDetail.soy b/resources/com/google/gitiles/templates/LogDetail.soy
index e3c78a8..c09c9f6 100644
--- a/resources/com/google/gitiles/templates/LogDetail.soy
+++ b/resources/com/google/gitiles/templates/LogDetail.soy
@@ -28,9 +28,9 @@
 {call .header data="all" /}
 
 {if $tags}
-  {foreach $tag in $tags}
+  {for $tag in $tags}
     {call gitiles.tagDetail data="$tag" /}
-  {/foreach}
+  {/for}
 {/if}
 
 {call .streamingPlaceholder /}
@@ -120,14 +120,14 @@
 {sp}<span class="CommitLog-author" title="{$author.email}">{msg desc="commit author name"}by {$author.name}{/msg}</span>
 {sp}<span class="CommitLog-time" title="{$author.time}">· {$author.relativeTime}</span>
 {if length($branches)}
-  {foreach $branch in $branches}
+  {for $branch in $branches}
     {sp}<a class="CommitLog-branchLabel" href="{$branch.url}">{$branch.name}</a>
-  {/foreach}
+  {/for}
 {/if}
 {if length($tags)}
-  {foreach $tag in $tags}
+  {for $tag in $tags}
     {sp}<a class="CommitLog-tagLabel" href="{$tag.url}">{$tag.name}</a>
-  {/foreach}
+  {/for}
 {/if}
 
 {if $rename}
@@ -206,14 +206,14 @@
     </td>
     <td>
       {if length($branches)}
-        {foreach $branch in $branches}
+        {for $branch in $branches}
           {sp}<a href="{$branch.url}" class="branch-label">{$branch.name}</a>
-        {/foreach}
+        {/for}
       {/if}
       {if length($tags)}
-        {foreach $tag in $tags}
+        {for $tag in $tags}
           {sp}<a href="{$tag.url}" class="tag-label">{$tag.name}</a>
-        {/foreach}
+        {/for}
       {else}
         {sp}
       {/if}
diff --git a/resources/com/google/gitiles/templates/ObjectDetail.soy b/resources/com/google/gitiles/templates/ObjectDetail.soy
index abfa319..627bf96 100644
--- a/resources/com/google/gitiles/templates/ObjectDetail.soy
+++ b/resources/com/google/gitiles/templates/ObjectDetail.soy
@@ -69,7 +69,7 @@
       <th class="Metadata-title">{msg desc="Header for tree SHA entry"}tree{/msg}</th>
       <td><a href="{$treeUrl}">{$tree}</a></td>
     </tr>
-    {foreach $parent in $parents}
+    {for $parent in $parents}
       <tr>
         <th class="Metadata-title">{msg desc="Header for parent SHA"}parent{/msg}</th>
         <td>
@@ -82,7 +82,7 @@
           </span>
         </td>
       </tr>
-    {/foreach}
+    {/for}
   </table>
 </div>
 {call .message_}
@@ -92,7 +92,7 @@
 
 {if $diffTree and length($diffTree)}
   <ul class="DiffTree">
-    {foreach $entry in $diffTree}
+    {for $entry in $diffTree}
       <li>
         <a href="{$entry.url}">{$entry.path}</a>
         {switch $entry.changeType}
@@ -129,7 +129,7 @@
           {default}
         {/switch}
       </li>
-    {/foreach}
+    {/for}
   </ul>
   <div class="DiffSummary">
     {if length($diffTree) == 1}
@@ -172,7 +172,7 @@
 
   {if length($entries)}
     <ol class="FileList">
-      {foreach $entry in $entries}
+      {for $entry in $entries}
         <li class="FileList-item{sp}
               {switch $entry.type}
                 {case 'TREE'}FileList-item--gitTree
@@ -205,7 +205,7 @@
           {/if}
           // TODO(dborowitz): Something reasonable for gitlinks.
         </li>
-      {/foreach}
+      {/for}
     </ol>
   {else}
     <p>{msg desc="Informational text for when a tree is empty"}This tree is empty.{/msg}</p>
@@ -256,18 +256,18 @@
   {if $lines != null}
     {if $lines}
       <table class="FileContents">
-        {foreach $line in $lines}
+        {for $line in $lines}
           {let $n: index($line) + 1 /}
           <tr class="u-pre u-monospace FileContents-line">
             <td class="u-lineNum u-noSelect FileContents-lineNum"
                 data-line-number="{$n}" onclick="window.location.hash='#{$n}'"></td>
             <td class="FileContents-lineContents" id="{$n}">
-              {foreach $span in $line}
+              {for $span in $line}
                 <span class="{$span.classes}">{$span.text}</span>
-              {/foreach}
+              {/for}
             </td>
           </tr>
-        {/foreach}
+        {/for}
       </table>
     {else}
       <div class="FileContents-empty">Empty file</div>
@@ -338,8 +338,8 @@
  */
 {template .message_ visibility="private"}
 <pre class="{$className}">
-  {foreach $part in $message}
+  {for $part in $message}
     {if $part.url}<a href="{$part.url}">{$part.text}</a>{else}{$part.text}{/if}
-  {/foreach}
+  {/for}
 </pre>
 {/template}
diff --git a/resources/com/google/gitiles/templates/RefList.soy b/resources/com/google/gitiles/templates/RefList.soy
index fe7f2d9..b1bb8ed 100644
--- a/resources/com/google/gitiles/templates/RefList.soy
+++ b/resources/com/google/gitiles/templates/RefList.soy
@@ -64,9 +64,9 @@
   <div class="RefList">
     <h3 class="RefList-title">{$type}</h3>
     <ul class="RefList-items">
-    {foreach $ref in $refs}
+    {for $ref in $refs}
       <li class="RefList-item"><a href="{$ref.url}">{$ref.name}</a></li>
-    {/foreach}
+    {/for}
     </ul>
   </div>
 {/template}
diff --git a/resources/com/google/gitiles/templates/RevisionDetail.soy b/resources/com/google/gitiles/templates/RevisionDetail.soy
index e4a48f9..2667afe 100644
--- a/resources/com/google/gitiles/templates/RevisionDetail.soy
+++ b/resources/com/google/gitiles/templates/RevisionDetail.soy
@@ -42,7 +42,7 @@
   {call .header data="all" /}
 {/if}
 
-{foreach $object in $objects}
+{for $object in $objects}
   {switch $object.type}
     {case 'commit'}
       {call .commitDetail data="$object.data" /}
@@ -57,7 +57,7 @@
         {msg desc="Error message for an unknown object type"}Object has unknown type.{/msg}
       </div>
   {/switch}
-{/foreach}
+{/for}
 
 {call .footer}
   {param customVariant: $customVariant /}