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] 4a7373333f
PiperOrigin-RevId: 180807358
Change-Id: I6f6416b4265d7fb1a7f933bc9ed24466b3637d40
This commit is contained in:
parent
843ea31dce
commit
57073ffd9d
@ -38,18 +38,18 @@
|
|||||||
{\n}
|
{\n}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{foreach $group in $commentFiles}
|
{for $group in $commentFiles}
|
||||||
{$group.link}{\n}
|
{$group.link}{\n}
|
||||||
{$group.title}:{\n}
|
{$group.title}:{\n}
|
||||||
{\n}
|
{\n}
|
||||||
|
|
||||||
{foreach $comment in $group.comments}
|
{for $comment in $group.comments}
|
||||||
{if $comment.isRobotComment}
|
{if $comment.isRobotComment}
|
||||||
Robot Comment from {$comment.robotId} (run ID {$comment.robotRunId}):
|
Robot Comment from {$comment.robotId} (run ID {$comment.robotRunId}):
|
||||||
{\n}
|
{\n}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{foreach $line in $comment.lines}
|
{for $line in $comment.lines}
|
||||||
{if isFirst($line)}
|
{if isFirst($line)}
|
||||||
{if $comment.startLine != 0}
|
{if $comment.startLine != 0}
|
||||||
{$comment.link}
|
{$comment.link}
|
||||||
@ -59,7 +59,7 @@
|
|||||||
{$comment.linePrefixEmpty}
|
{$comment.linePrefixEmpty}
|
||||||
{/if}
|
{/if}
|
||||||
{$line}{\n}
|
{$line}{\n}
|
||||||
{/foreach}
|
{/for}
|
||||||
{if length($comment.lines) == 0}
|
{if length($comment.lines) == 0}
|
||||||
{$comment.linePrefix}{\n}
|
{$comment.linePrefix}{\n}
|
||||||
{/if}
|
{/if}
|
||||||
@ -70,7 +70,7 @@
|
|||||||
{$comment.message}{\n}
|
{$comment.message}{\n}
|
||||||
{\n}
|
{\n}
|
||||||
{\n}
|
{\n}
|
||||||
{/foreach}
|
{/for}
|
||||||
{/foreach}
|
{/for}
|
||||||
{\n}
|
{\n}
|
||||||
{/template}
|
{/template}
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
{if length($labels) > 0}
|
{if length($labels) > 0}
|
||||||
<p>
|
<p>
|
||||||
Patch set {$patchSet.patchSetId}:
|
Patch set {$patchSet.patchSetId}:
|
||||||
{foreach $label in $labels}
|
{for $label in $labels}
|
||||||
{if $label.value > 0}
|
{if $label.value > 0}
|
||||||
<span style="{$positiveVoteStyle}">
|
<span style="{$positiveVoteStyle}">
|
||||||
{$label.label}{sp}+{$label.value}
|
{$label.label}{sp}+{$label.value}
|
||||||
@ -93,7 +93,7 @@
|
|||||||
-{$label.label}
|
-{$label.label}
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
{/foreach}
|
{/for}
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
@ -110,14 +110,14 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<ul style="{$ulStyle}">
|
<ul style="{$ulStyle}">
|
||||||
{foreach $group in $commentFiles}
|
{for $group in $commentFiles}
|
||||||
<li style="{$fileLiStyle}">
|
<li style="{$fileLiStyle}">
|
||||||
<p>
|
<p>
|
||||||
<a href="{$group.link}">{$group.title}:</a>
|
<a href="{$group.link}">{$group.title}:</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<ul style="{$ulStyle}">
|
<ul style="{$ulStyle}">
|
||||||
{foreach $comment in $group.comments}
|
{for $comment in $group.comments}
|
||||||
<li style="{$commentLiStyle}">
|
<li style="{$commentLiStyle}">
|
||||||
{if $comment.isRobotComment}
|
{if $comment.isRobotComment}
|
||||||
<p style="{$commentHeaderStyle}">
|
<p style="{$commentHeaderStyle}">
|
||||||
@ -149,9 +149,9 @@
|
|||||||
<p>
|
<p>
|
||||||
<blockquote style="{$blockquoteStyle}">
|
<blockquote style="{$blockquoteStyle}">
|
||||||
{call .Pre}{param content kind="html"}
|
{call .Pre}{param content kind="html"}
|
||||||
{foreach $line in $comment.lines}
|
{for $line in $comment.lines}
|
||||||
{$line}{\n}
|
{$line}{\n}
|
||||||
{/foreach}
|
{/for}
|
||||||
{/param}{/call}
|
{/param}{/call}
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</p>
|
</p>
|
||||||
@ -167,9 +167,9 @@
|
|||||||
|
|
||||||
{call .WikiFormat}{param content: $comment.messageBlocks /}{/call}
|
{call .WikiFormat}{param content: $comment.messageBlocks /}{/call}
|
||||||
</li>
|
</li>
|
||||||
{/foreach}
|
{/for}
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
{/foreach}
|
{/for}
|
||||||
</ul>
|
</ul>
|
||||||
{/template}
|
{/template}
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
*/
|
*/
|
||||||
{template .DeleteReviewer kind="text"}
|
{template .DeleteReviewer kind="text"}
|
||||||
{$fromName} has removed{sp}
|
{$fromName} has removed{sp}
|
||||||
{foreach $reviewerName in $email.reviewerNames}
|
{for $reviewerName in $email.reviewerNames}
|
||||||
{if not isFirst($reviewerName)},{sp}{/if}
|
{if not isFirst($reviewerName)},{sp}{/if}
|
||||||
{$reviewerName}
|
{$reviewerName}
|
||||||
{/foreach}{sp}
|
{/for}{sp}
|
||||||
from this change.{sp}
|
from this change.{sp}
|
||||||
{if $email.changeUrl} ( {$email.changeUrl} ){/if}{\n}
|
{if $email.changeUrl} ( {$email.changeUrl} ){/if}{\n}
|
||||||
{\n}
|
{\n}
|
||||||
|
@ -25,12 +25,12 @@
|
|||||||
{$fromName}{sp}
|
{$fromName}{sp}
|
||||||
<strong>
|
<strong>
|
||||||
removed{sp}
|
removed{sp}
|
||||||
{foreach $reviewerName in $email.reviewerNames}
|
{for $reviewerName in $email.reviewerNames}
|
||||||
{if not isFirst($reviewerName)}
|
{if not isFirst($reviewerName)}
|
||||||
{if isLast($reviewerName)}{sp}and{else},{/if}{sp}
|
{if isLast($reviewerName)}{sp}and{else},{/if}{sp}
|
||||||
{/if}
|
{/if}
|
||||||
{$reviewerName}
|
{$reviewerName}
|
||||||
{/foreach}
|
{/for}
|
||||||
</strong>{sp}
|
</strong>{sp}
|
||||||
from this change.
|
from this change.
|
||||||
</p>
|
</p>
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* @param footers
|
* @param footers
|
||||||
*/
|
*/
|
||||||
{template .Footer kind="text"}
|
{template .Footer kind="text"}
|
||||||
{foreach $footer in $footers}
|
{for $footer in $footers}
|
||||||
{$footer}{\n}
|
{$footer}{\n}
|
||||||
{/foreach}
|
{/for}
|
||||||
{/template}
|
{/template}
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
{template .FooterHtml}
|
{template .FooterHtml}
|
||||||
{\n}
|
{\n}
|
||||||
{\n}
|
{\n}
|
||||||
{foreach $footer in $footers}
|
{for $footer in $footers}
|
||||||
<div style="display:none">{sp}{$footer}{sp}</div>{\n}
|
<div style="display:none">{sp}{$footer}{sp}</div>{\n}
|
||||||
{/foreach}
|
{/for}
|
||||||
{\n}
|
{\n}
|
||||||
{/template}
|
{/template}
|
||||||
|
@ -28,10 +28,10 @@
|
|||||||
{template .NewChange kind="text"}
|
{template .NewChange kind="text"}
|
||||||
{if $email.reviewerNames}
|
{if $email.reviewerNames}
|
||||||
Hello{sp}
|
Hello{sp}
|
||||||
{foreach $reviewerName in $email.reviewerNames}
|
{for $reviewerName in $email.reviewerNames}
|
||||||
{if not isFirst($reviewerName)},{sp}{/if}
|
{if not isFirst($reviewerName)},{sp}{/if}
|
||||||
{$reviewerName}
|
{$reviewerName}
|
||||||
{/foreach},
|
{/for},
|
||||||
|
|
||||||
{\n}
|
{\n}
|
||||||
{\n}
|
{\n}
|
||||||
|
@ -28,12 +28,12 @@
|
|||||||
<p>
|
<p>
|
||||||
{if $email.reviewerNames}
|
{if $email.reviewerNames}
|
||||||
{$fromName} would like{sp}
|
{$fromName} would like{sp}
|
||||||
{foreach $reviewerName in $email.reviewerNames}
|
{for $reviewerName in $email.reviewerNames}
|
||||||
{if not isFirst($reviewerName)}
|
{if not isFirst($reviewerName)}
|
||||||
{if isLast($reviewerName)}{sp}and{else},{/if}{sp}
|
{if isLast($reviewerName)}{sp}and{else},{/if}{sp}
|
||||||
{/if}
|
{/if}
|
||||||
{$reviewerName}
|
{$reviewerName}
|
||||||
{/foreach}{sp}
|
{/for}{sp}
|
||||||
to <strong>review</strong> this change.
|
to <strong>review</strong> this change.
|
||||||
{else}
|
{else}
|
||||||
{$ownerName} has uploaded this change for <strong>review</strong>.
|
{$ownerName} has uploaded this change for <strong>review</strong>.
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
{/let}
|
{/let}
|
||||||
|
|
||||||
{foreach $block in $content}
|
{for $block in $content}
|
||||||
{if $block.type == 'paragraph'}
|
{if $block.type == 'paragraph'}
|
||||||
<p style="{$pStyle}">{$block.text|changeNewlineToBr}</p>
|
<p style="{$pStyle}">{$block.text|changeNewlineToBr}</p>
|
||||||
{elseif $block.type == 'quote'}
|
{elseif $block.type == 'quote'}
|
||||||
@ -79,12 +79,12 @@
|
|||||||
{call .Pre}{param content: $block.text /}{/call}
|
{call .Pre}{param content: $block.text /}{/call}
|
||||||
{elseif $block.type == 'list'}
|
{elseif $block.type == 'list'}
|
||||||
<ul>
|
<ul>
|
||||||
{foreach $item in $block.items}
|
{for $item in $block.items}
|
||||||
<li>{$item}</li>
|
<li>{$item}</li>
|
||||||
{/foreach}
|
{/for}
|
||||||
</ul>
|
</ul>
|
||||||
{/if}
|
{/if}
|
||||||
{/foreach}
|
{/for}
|
||||||
{/template}
|
{/template}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,7 +106,7 @@
|
|||||||
{/let}
|
{/let}
|
||||||
|
|
||||||
<pre style="{$preStyle}">
|
<pre style="{$preStyle}">
|
||||||
{foreach $line in $diffLines}
|
{for $line in $diffLines}
|
||||||
{if $line.type == 'add'}
|
{if $line.type == 'add'}
|
||||||
<span style="{$addStyle}">
|
<span style="{$addStyle}">
|
||||||
{elseif $line.type == 'remove'}
|
{elseif $line.type == 'remove'}
|
||||||
@ -116,6 +116,6 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{$line.text}
|
{$line.text}
|
||||||
</span><br>
|
</span><br>
|
||||||
{/foreach}
|
{/for}
|
||||||
</pre>
|
</pre>
|
||||||
{/template}
|
{/template}
|
||||||
|
@ -29,9 +29,9 @@
|
|||||||
{template .ReplacePatchSet kind="text"}
|
{template .ReplacePatchSet kind="text"}
|
||||||
{if $email.reviewerNames and $fromEmail == $change.ownerEmail}
|
{if $email.reviewerNames and $fromEmail == $change.ownerEmail}
|
||||||
Hello{sp}
|
Hello{sp}
|
||||||
{foreach $reviewerName in $email.reviewerNames}
|
{for $reviewerName in $email.reviewerNames}
|
||||||
{$reviewerName},{sp}
|
{$reviewerName},{sp}
|
||||||
{/foreach}{\n}
|
{/for}{\n}
|
||||||
{\n}
|
{\n}
|
||||||
I'd like you to reexamine a change.
|
I'd like you to reexamine a change.
|
||||||
{if $email.changeUrl}
|
{if $email.changeUrl}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user