Roll back changelist 180942763

*** Reason for rollback ***

Breaks the FOSS build.

We'll reincorporate this change once Closure Rules is properly updated to accommodate it.

*** Original change description ***

Change all foreach loops in Soy templates to use the 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 gramma...

***

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=180961695
This commit is contained in:
mcilwain 2018-01-05 12:37:30 -08:00 committed by Ben McIlwain
parent d52a701f50
commit ffcfa283f6
24 changed files with 103 additions and 109 deletions

View file

@ -1458,10 +1458,10 @@ def com_google_re2j():
def com_google_template_soy():
java_import_external(
name = "com_google_template_soy",
jar_sha256 = "2952b430323a01070d73c7767e34c4030355b9e60c14b5165bebf69b2f6ad927",
jar_sha256 = "3c4e61234e9ee9f79411da997e23b201bcf281255469c76d162dac07a67dbb78",
jar_urls = [
"http://repo1.maven.org/maven2/com/google/template/soy/2018-01-03/soy-2018-01-03.jar",
"http://central.maven.org/maven2/com/google/template/soy/2018-01-03/soy-2018-01-03.jar",
"http://repo1.maven.org/maven2/com/google/template/soy/2017-06-22/soy-2017-06-22.jar",
"http://central.maven.org/maven2/com/google/template/soy/2017-06-22/soy-2017-06-22.jar",
],
deps = [
"@args4j",

View file

@ -48,9 +48,9 @@
{/if}
<contact:addr>
{if $street}
{for $s in $street}
{foreach $s in $street}
<contact:street>{$s}</contact:street>
{/for}
{/foreach}
{/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>
{for $nameserver in $nameservers}
{foreach $nameserver in $nameservers}
<domain:hostObj>{$nameserver}</domain:hostObj>
{/for}
{/foreach}
</domain:ns>
{/if}
<domain:registrant>{$registrant}</domain:registrant>
{for $type in keys($contacts)}
{foreach $type in keys($contacts)}
<domain:contact type="{$type}">{$contacts[$type]}</domain:contact>
{/for}
{/foreach}
<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">
{for $dsRecord in $dsRecords}
{foreach $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>
{/for}
{/foreach}
</secDNS:create>
{/if}
</extension>

View file

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

View file

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

View file

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

View file

@ -42,40 +42,40 @@
<domain:add>
{if length($addNameservers) > 0}
<domain:ns>
{for $s in $addNameservers}
{foreach $s in $addNameservers}
<domain:hostObj>{$s}</domain:hostObj>
{/for}
{/foreach}
</domain:ns>
{/if}
{for $admin in $addAdmins}
{foreach $admin in $addAdmins}
<domain:contact type="admin">{$admin}</domain:contact>
{/for}
{for $tech in $addTechs}
{/foreach}
{foreach $tech in $addTechs}
<domain:contact type="tech">{$tech}</domain:contact>
{/for}
{for $status in $addStatuses}
{/foreach}
{foreach $status in $addStatuses}
<domain:status s="{$status}"/>
{/for}
{/foreach}
</domain:add>
{/if}
{if $remove}
<domain:rem>
{if length($removeNameservers) > 0}
<domain:ns>
{for $s in $removeNameservers}
{foreach $s in $removeNameservers}
<domain:hostObj>{$s}</domain:hostObj>
{/for}
{/foreach}
</domain:ns>
{/if}
{for $admin in $removeAdmins}
{foreach $admin in $removeAdmins}
<domain:contact type="admin">{$admin}</domain:contact>
{/for}
{for $tech in $removeTechs}
{/foreach}
{foreach $tech in $removeTechs}
<domain:contact type="tech">{$tech}</domain:contact>
{/for}
{for $status in $removeStatuses}
{/foreach}
{foreach $status in $removeStatuses}
<domain:status s="{$status}"/>
{/for}
{/foreach}
</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}
{for $ipv4 in $ipv4addresses}
{foreach $ipv4 in $ipv4addresses}
<host:addr ip="v4">{$ipv4}</host:addr>
{/for}
{/foreach}
{/if}
{if $ipv6addresses}
{for $ipv6 in $ipv6addresses}
{foreach $ipv6 in $ipv6addresses}
<host:addr ip="v6">{$ipv6}</host:addr>
{/for}
{/foreach}
{/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>
{for $ip in $ipAddresses}
{foreach $ip in $ipAddresses}
<host:rem>
<host:addr ip="{$ip['type']}">{$ip['address']}</host:addr>
</host:rem>
{/for}
{/foreach}
</host:update>
</update>
<extension>

View file

@ -34,26 +34,26 @@
<domain:add>
{if length($hostsToAdd) > 0}
<domain:ns>
{for $ha in $hostsToAdd}
{foreach $ha in $hostsToAdd}
<domain:hostObj>{$ha}</domain:hostObj>
{/for}
{/foreach}
</domain:ns>
{/if}
{for $la in $locksToApply}
{foreach $la in $locksToApply}
<domain:status s="{$la}" />
{/for}
{/foreach}
</domain:add>
<domain:rem>
{if length($hostsToRemove) > 0}
<domain:ns>
{for $hr in $hostsToRemove}
{foreach $hr in $hostsToRemove}
<domain:hostObj>{$hr}</domain:hostObj>
{/for}
{/foreach}
</domain:ns>
{/if}
{for $lr in $locksToRemove}
{foreach $lr in $locksToRemove}
<domain:status s="{$lr}" />
{/for}
{/foreach}
</domain:rem>
</domain:update>
</update>
@ -64,14 +64,14 @@
</secDNS:rem>
{if length($newDsData) > 0}
<secDNS:add>
{for $ds in $newDsData}
{foreach $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>
{/for}
{/foreach}
</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>
{for $a in $locksToApply}
{foreach $a in $locksToApply}
<domain:status s="{$a}" lang="en"></domain:status>
{/for}
{/foreach}
</domain:add>
<domain:rem>
{for $r in $locksToRemove}
{foreach $r in $locksToRemove}
<domain:status s="{$r}" lang="en"></domain:status>
{/for}
{/foreach}
</domain:rem>
</domain:update>
</update>

View file

@ -10,9 +10,6 @@ closure_js_template_library(
name = "soy",
srcs = glob(["*.soy"]),
globals = "//java/google/registry/ui:globals.txt",
# TODO: remove this when upgrading rules closure. This is only necessary because
# our version of soy is newer than what rules closure expects
should_generate_js_doc = False,
)
closure_java_template_library(

View file

@ -244,11 +244,11 @@
name="{$name}"
class="{css('kd-button')} {css('reg-select')}"
{if $readonly}disabled{/if}>
{for $option in $options}
{foreach $option in $options}
<option value="{$option}" {if $selected == $option}selected{/if}>
{$option}
</option>
{/for}
{/foreach}
</select>
</td>
</tr>
@ -263,12 +263,12 @@
{template .inputRadioWithValue}
<tr>
<td colspan="2">
{for $value in $values}
{foreach $value in $values}
<input type="radio"
name="{$name}"
value="{$value}"
{if $checkedValue == $value}checked{/if}>
{/for}
{/foreach}
</td>
</tr>
{/template}
@ -309,13 +309,13 @@
</span>
<span class="{css('kd-disclosureindicator')}"></span>
<ul class="{css('kd-menulist')}">
{for $item in $items}
{foreach $item in $items}
<li class="{css('kd-menulistitem')}
{if $item == $selected}
{sp}{css('selected')}
{/if}">
{$item}
{/for}
{/foreach}
</ul>
</div>
{/template}

View file

@ -11,9 +11,6 @@ closure_js_template_library(
srcs = glob(["*.soy"]),
data = ["//java/google/registry/ui/css:registrar_raw"],
globals = "//java/google/registry/ui:globals.txt",
# TODO: remove this when upgrading rules closure. This is only necessary because
# our version of soy is newer than what rules closure expects
should_generate_js_doc = False,
deps = ["//java/google/registry/ui/soy"],
)

View file

@ -89,13 +89,13 @@
<td colspan="2">
<div id="contact-postalInfo">
{if isNonnull($item['contact:postalInfo'])}
{for $pi in $item['contact:postalInfo']}
{foreach $pi in $item['contact:postalInfo']}
{call .postalInfo data="all"}
{param localized: index($pi) == 1 /}
{param item: $pi/}
{param namePrefix: 'contact:postalInfo[' + index($pi) + '].contact:' /}
{/call}
{/for}
{/foreach}
{else}
{call .postalInfo data="all"}
{param namePrefix: 'contact:postalInfo[0].contact:' /}

View file

@ -28,7 +28,7 @@
<create>
<contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
<contact:id>{$item['contact:id']}</contact:id>
{for $pi in $item['contact:postalInfo']}
{foreach $pi in $item['contact:postalInfo']}
<contact:postalInfo type="{if index($pi) == 0}int{else}loc{/if}">
<contact:name>{$pi['contact:name']}</contact:name>
<contact:org>{$pi['contact:org']}</contact:org>
@ -41,7 +41,7 @@
<contact:cc>{$addr['contact:cc']}</contact:cc>
</contact:addr>
</contact:postalInfo>
{/for}
{/foreach}
<contact:voice>{$item['contact:voice']}</contact:voice>
<contact:fax>{$item['contact:fax']}</contact:fax>
<contact:email>{$item['contact:email']}</contact:email>
@ -70,7 +70,7 @@
<contact:update xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
<contact:id>{$item['contact:id']}</contact:id>
<contact:chg>
{for $pi in $item['contact:postalInfo']}
{foreach $pi in $item['contact:postalInfo']}
<contact:postalInfo type="{if index($pi) == 0}int{else}loc{/if}">
<contact:name>{$pi['contact:name']}</contact:name>
<contact:org>{$pi['contact:org']}</contact:org>
@ -83,7 +83,7 @@
<contact:cc>{$addr['contact:cc']}</contact:cc>
</contact:addr>
</contact:postalInfo>
{/for}
{/foreach}
<contact:voice>{$item['contact:voice']}</contact:voice>
<contact:fax>{$item['contact:fax']}</contact:fax>
<contact:email>{$item['contact:email']}</contact:email>

View file

@ -30,7 +30,7 @@
<div class="{css('set')}">
<h1>Contact settings</h1>
<table>
{for $type in $possibleTypesLookup}
{foreach $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')}">
{for $c in $contactsByType[$type[0]]}
{foreach $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}
{/for}
{/foreach}
</td>
{/if}
{/for}
{/foreach}
</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')}">
{for $type in $possibleTypesLookup}
{foreach $type in $possibleTypesLookup}
{if $actualTypesLookup[$type[0]]}
<div>{$type[1]} contact</div>
{/if}
{/for}
{/foreach}
</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>>}
{for $type in $possibleTypesLookup}
{foreach $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>
{/for}
{/foreach}
{/template}

View file

@ -113,7 +113,7 @@
</th>
</tr>
{if isNonnull($item['domain:ns'] and isNonnull($item['domain:ns']['domain:hostObj']))}
{for $hostObj in $item['domain:ns']['domain:hostObj']}
{foreach $hostObj in $item['domain:ns']['domain:hostObj']}
{let $hostIdx: index($hostObj) /}
{call registry.soy.forms.inputFieldRowWithValue data="all"}
{param label: 'Host ' + $hostIdx /}
@ -121,7 +121,7 @@
{param value: $hostObj /}
{param clazz kind="text"}{css('domain-hostObj')}{/param}
{/call}
{/for}
{/foreach}
{/if}
<tr id="domain-hosts-footer"></tr>
@ -165,7 +165,7 @@
{template .showContact_ visibility="private"}
{@param contacts: list<map<string, ?>>} /** List of EPP domain:contacts. */
{@param type: string} /** Type of contact (e.g. admin, tech) */
{for $contact in $contacts}
{foreach $contact in $contacts}
{if $type == $contact['@type']}
{call registry.soy.forms.inputFieldRowWithValue data="all"}
{param label: $contact['@type'] + ' contact' /}
@ -177,7 +177,7 @@
type="hidden"
value="{$contact['@type']}">
{/if}
{/for}
{/foreach}
{/template}

View file

@ -32,18 +32,18 @@
{/if}
{if isNonnull($item['domain:ns'])}
<domain:ns>
{for $hostObj in $item['domain:ns']['domain:hostObj']}
{foreach $hostObj in $item['domain:ns']['domain:hostObj']}
<domain:hostObj>{$hostObj.value}</domain:hostObj>
{/for}
{/foreach}
</domain:ns>
{/if}
{if isNonnull($item['domain:registrant'])}
<domain:registrant>{$item['domain:registrant']}</domain:registrant>
{/if}
{if isNonnull($item['domain:contact'])}
{for $contact in $item['domain:contact']}
{foreach $contact in $item['domain:contact']}
<domain:contact type="{$contact['@type']}">{$contact.value}</domain:contact>
{/for}
{/foreach}
{/if}
<domain:authInfo>
<domain:pw>{$item['domain:authInfo']['domain:pw']}</domain:pw>
@ -128,15 +128,15 @@
<{$tagName}>
{if isNonnull($hosts)}
<domain:ns>
{for $host in $hosts}
{foreach $host in $hosts}
<domain:hostObj>{$host.value}</domain:hostObj>
{/for}
{/foreach}
</domain:ns>
{/if}
{if isNonnull($contacts)}
{for $contact in $contacts}
{foreach $contact in $contacts}
<domain:contact type="{$contact['@type']}">{$contact.value}</domain:contact>
{/for}
{/foreach}
{/if}
</{$tagName}>
{/template}

View file

@ -59,7 +59,7 @@
</th>
</tr>
{if isNonnull($item['host:addr'])}
{for $addr in $item['host:addr']}
{foreach $addr in $item['host:addr']}
{if not $readonly}
<input type="hidden"
name="host:oldAddr[{index($addr)}].value"
@ -70,7 +70,7 @@
{param name: 'host:addr[' + index($addr) + '].value' /}
{param value: $item['host:addr'][index($addr)] /}
{/call}
{/for}
{/foreach}
{/if}
<tr id="domain-host-addrs-footer"></tr>
</table>

View file

@ -27,10 +27,10 @@
<host:create xmlns:host="urn:ietf:params:xml:ns:host-1.0">
<host:name>{$item['host:name']}</host:name>
{if isNonnull($item['host:addr'])}
{for $addr in $item['host:addr']}
{foreach $addr in $item['host:addr']}
{let $type: strContains($addr['value'], ':') ? 'v6' : 'v4' /}
<host:addr ip="{$type}">{$addr['value']}</host:addr>
{/for}
{/foreach}
{/if}
</host:create>
</create>
@ -101,10 +101,10 @@
{let $tagName: $isAdd ? 'host:add' : 'host:rem' /}
{if length($addrs) > 0}
<{$tagName}>
{for $addr in $addrs}
{foreach $addr in $addrs}
{let $type: strContains($addr, ':') ? 'v6' : 'v4' /}
<host:addr ip="{$type}">{$addr}</host:addr>
{/for}
{/foreach}
</{$tagName}>
{/if}
{/template}

View file

@ -47,12 +47,12 @@
<td class="{css('setting')}">
<div class="{css('info')} {css('summary')}">
<div id="ips">
{for $ip in $ipAddressWhitelist}
{foreach $ip in $ipAddressWhitelist}
{call .ip}
{param name: 'ipAddressWhitelist[' + index($ip) + ']' /}
{param ip: $ip /}
{/call}
{/for}
{/foreach}
</div>
<div class="{css('hidden')}">
<input id="newIp" value="" placeholder="Enter IP address..."/>

View file

@ -149,13 +149,13 @@
{@param? state: string}
{@param? zip: string}
{@param countryCode: string}
{for $line in $street}
{foreach $line in $street}
<input type="hidden"
name="{$id}.street[{index($line)}]"
id="{$id}.street[{index($line)}]"
value="{$street[index($line)]}">
<div class="{css('contact-address-street')}">{$street[index($line)]}</div>
{/for}
{/foreach}
<input type="hidden" name="{$id}.city" id="{$id}.city" value="{$city}">
<input type="hidden" name="{$id}.state" id="{$id}.state" value="{$state}">
<input type="hidden" name="{$id}.zip" id="{$id}.zip" value="{$zip}">