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

@ -48,9 +48,9 @@
{/if}
<contact:addr>
{if $street}
{foreach $s in $street}
{for $s in $street}
<contact:street>{$s}</contact:street>
{/foreach}
{/for}
{/if}
{if $city}
<contact:city>{$city}</contact:city>

View file

@ -39,15 +39,15 @@
<domain:period unit="y">{$period}</domain:period>
{if isNonnull($nameservers) and length($nameservers) > 0}
<domain:ns>
{foreach $nameserver in $nameservers}
{for $nameserver in $nameservers}
<domain:hostObj>{$nameserver}</domain:hostObj>
{/foreach}
{/for}
</domain:ns>
{/if}
<domain:registrant>{$registrant}</domain:registrant>
{foreach $type in keys($contacts)}
{for $type in keys($contacts)}
<domain:contact type="{$type}">{$contacts[$type]}</domain:contact>
{/foreach}
{/for}
<domain:authInfo>
<domain:pw>{$authInfo}</domain:pw>
</domain:authInfo>
@ -70,14 +70,14 @@
</allocate:create>
{if isNonnull($dsRecords) and length($dsRecords) > 0}
<secDNS:create xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
{foreach $dsRecord in $dsRecords}
{for $dsRecord in $dsRecords}
<secDNS:dsData>
<secDNS:keyTag>{$dsRecord['keyTag']}</secDNS:keyTag>
<secDNS:alg>{$dsRecord['algorithm']}</secDNS:alg>
<secDNS:digestType>{$dsRecord['digestType']}</secDNS:digestType>
<secDNS:digest>{$dsRecord['digest']}</secDNS:digest>
</secDNS:dsData>
{/foreach}
{/for}
</secDNS:create>
{/if}
</extension>

View file

@ -24,9 +24,9 @@
<command>
<check>
<domain:check xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
{foreach $d in $domainNames}
{for $d in $domainNames}
<domain:name>{$d}</domain:name>
{/foreach}
{/for}
</domain:check>
</check>
<clTRID>RegistryTool</clTRID>

View file

@ -24,9 +24,9 @@
<command>
<check>
<domain:check xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
{foreach $d in $domainNames}
{for $d in $domainNames}
<domain:name>{$d}</domain:name>
{/foreach}
{/for}
</domain:check>
</check>
<extension>

View file

@ -24,20 +24,20 @@
<command>
<check>
<domain:check xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
{foreach $d in $domainNames}
{for $d in $domainNames}
<domain:name>{$d}</domain:name>
{/foreach}
{/for}
</domain:check>
</check>
<extension>
<fee:check xmlns:fee="urn:ietf:params:xml:ns:fee-0.6">
{foreach $d in $domainNames}
{for $d in $domainNames}
<fee:domain>
<fee:name>{$d}</fee:name>
<fee:command>create</fee:command>
<fee:period unit="y">1</fee:period>
</fee:domain>
{/foreach}
{/for}
</fee:check>
</extension>
<clTRID>RegistryTool</clTRID>

View file

@ -36,18 +36,18 @@
{/if}
{if length($nameservers) > 0}
<domain:ns>
{foreach $s in $nameservers}
{for $s in $nameservers}
<domain:hostObj>{$s}</domain:hostObj>
{/foreach}
{/for}
</domain:ns>
{/if}
<domain:registrant>{$registrant}</domain:registrant>
{foreach $admin in $admins}
{for $admin in $admins}
<domain:contact type="admin">{$admin}</domain:contact>
{/foreach}
{foreach $tech in $techs}
{/for}
{for $tech in $techs}
<domain:contact type="tech">{$tech}</domain:contact>
{/foreach}
{/for}
<domain:authInfo>
<domain:pw>{$password}</domain:pw>
</domain:authInfo>

View file

@ -42,40 +42,40 @@
<domain:add>
{if length($addNameservers) > 0}
<domain:ns>
{foreach $s in $addNameservers}
{for $s in $addNameservers}
<domain:hostObj>{$s}</domain:hostObj>
{/foreach}
{/for}
</domain:ns>
{/if}
{foreach $admin in $addAdmins}
{for $admin in $addAdmins}
<domain:contact type="admin">{$admin}</domain:contact>
{/foreach}
{foreach $tech in $addTechs}
{/for}
{for $tech in $addTechs}
<domain:contact type="tech">{$tech}</domain:contact>
{/foreach}
{foreach $status in $addStatuses}
{/for}
{for $status in $addStatuses}
<domain:status s="{$status}"/>
{/foreach}
{/for}
</domain:add>
{/if}
{if $remove}
<domain:rem>
{if length($removeNameservers) > 0}
<domain:ns>
{foreach $s in $removeNameservers}
{for $s in $removeNameservers}
<domain:hostObj>{$s}</domain:hostObj>
{/foreach}
{/for}
</domain:ns>
{/if}
{foreach $admin in $removeAdmins}
{for $admin in $removeAdmins}
<domain:contact type="admin">{$admin}</domain:contact>
{/foreach}
{foreach $tech in $removeTechs}
{/for}
{for $tech in $removeTechs}
<domain:contact type="tech">{$tech}</domain:contact>
{/foreach}
{foreach $status in $removeStatuses}
{/for}
{for $status in $removeStatuses}
<domain:status s="{$status}"/>
{/foreach}
{/for}
</domain:rem>
{/if}
{if $change}

View file

@ -28,14 +28,14 @@
<host:create xmlns:host="urn:ietf:params:xml:ns:host-1.0">
<host:name>{$hostname}</host:name>
{if $ipv4addresses}
{foreach $ipv4 in $ipv4addresses}
{for $ipv4 in $ipv4addresses}
<host:addr ip="v4">{$ipv4}</host:addr>
{/foreach}
{/for}
{/if}
{if $ipv6addresses}
{foreach $ipv6 in $ipv6addresses}
{for $ipv6 in $ipv6addresses}
<host:addr ip="v6">{$ipv6}</host:addr>
{/foreach}
{/for}
{/if}
</host:create>
</create>

View file

@ -28,11 +28,11 @@
<host:update
xmlns:host="urn:ietf:params:xml:ns:host-1.0">
<host:name>{$name}</host:name>
{foreach $ip in $ipAddresses}
{for $ip in $ipAddresses}
<host:rem>
<host:addr ip="{$ip['type']}">{$ip['address']}</host:addr>
</host:rem>
{/foreach}
{/for}
</host:update>
</update>
<extension>

View file

@ -34,26 +34,26 @@
<domain:add>
{if length($hostsToAdd) > 0}
<domain:ns>
{foreach $ha in $hostsToAdd}
{for $ha in $hostsToAdd}
<domain:hostObj>{$ha}</domain:hostObj>
{/foreach}
{/for}
</domain:ns>
{/if}
{foreach $la in $locksToApply}
{for $la in $locksToApply}
<domain:status s="{$la}" />
{/foreach}
{/for}
</domain:add>
<domain:rem>
{if length($hostsToRemove) > 0}
<domain:ns>
{foreach $hr in $hostsToRemove}
{for $hr in $hostsToRemove}
<domain:hostObj>{$hr}</domain:hostObj>
{/foreach}
{/for}
</domain:ns>
{/if}
{foreach $lr in $locksToRemove}
{for $lr in $locksToRemove}
<domain:status s="{$lr}" />
{/foreach}
{/for}
</domain:rem>
</domain:update>
</update>
@ -64,14 +64,14 @@
</secDNS:rem>
{if length($newDsData) > 0}
<secDNS:add>
{foreach $ds in $newDsData}
{for $ds in $newDsData}
<secDNS:dsData>
<secDNS:keyTag>{$ds.keyTag}</secDNS:keyTag>
<secDNS:alg>{$ds.alg}</secDNS:alg>
<secDNS:digestType>{$ds.digestType}</secDNS:digestType>
<secDNS:digest>{$ds.digest}</secDNS:digest>
</secDNS:dsData>
{/foreach}
{/for}
</secDNS:add>
{/if}
</secDNS:update>

View file

@ -31,14 +31,14 @@
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>{$domainName}</domain:name>
<domain:add>
{foreach $a in $locksToApply}
{for $a in $locksToApply}
<domain:status s="{$a}" lang="en"></domain:status>
{/foreach}
{/for}
</domain:add>
<domain:rem>
{foreach $r in $locksToRemove}
{for $r in $locksToRemove}
<domain:status s="{$r}" lang="en"></domain:status>
{/foreach}
{/for}
</domain:rem>
</domain:update>
</update>