mirror of
https://github.com/google/nomulus
synced 2026-02-04 12:02:30 +00:00
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:
@@ -244,11 +244,11 @@
|
||||
name="{$name}"
|
||||
class="{css('kd-button')} {css('reg-select')}"
|
||||
{if $readonly}disabled{/if}>
|
||||
{foreach $option in $options}
|
||||
{for $option in $options}
|
||||
<option value="{$option}" {if $selected == $option}selected{/if}>
|
||||
{$option}
|
||||
</option>
|
||||
{/foreach}
|
||||
{/for}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -263,12 +263,12 @@
|
||||
{template .inputRadioWithValue}
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
{foreach $value in $values}
|
||||
{for $value in $values}
|
||||
<input type="radio"
|
||||
name="{$name}"
|
||||
value="{$value}"
|
||||
{if $checkedValue == $value}checked{/if}>
|
||||
{/foreach}
|
||||
{/for}
|
||||
</td>
|
||||
</tr>
|
||||
{/template}
|
||||
@@ -309,13 +309,13 @@
|
||||
</span>
|
||||
<span class="{css('kd-disclosureindicator')}"></span>
|
||||
<ul class="{css('kd-menulist')}">
|
||||
{foreach $item in $items}
|
||||
{for $item in $items}
|
||||
<li class="{css('kd-menulistitem')}
|
||||
{if $item == $selected}
|
||||
{sp}{css('selected')}
|
||||
{/if}">
|
||||
{$item}
|
||||
{/foreach}
|
||||
{/for}
|
||||
</ul>
|
||||
</div>
|
||||
{/template}
|
||||
|
||||
@@ -89,13 +89,13 @@
|
||||
<td colspan="2">
|
||||
<div id="contact-postalInfo">
|
||||
{if isNonnull($item['contact:postalInfo'])}
|
||||
{foreach $pi in $item['contact:postalInfo']}
|
||||
{for $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}
|
||||
{/foreach}
|
||||
{/for}
|
||||
{else}
|
||||
{call .postalInfo data="all"}
|
||||
{param namePrefix: 'contact:postalInfo[0].contact:' /}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<create>
|
||||
<contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
|
||||
<contact:id>{$item['contact:id']}</contact:id>
|
||||
{foreach $pi in $item['contact:postalInfo']}
|
||||
{for $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>
|
||||
{/foreach}
|
||||
{/for}
|
||||
<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>
|
||||
{foreach $pi in $item['contact:postalInfo']}
|
||||
{for $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>
|
||||
{/foreach}
|
||||
{/for}
|
||||
<contact:voice>{$item['contact:voice']}</contact:voice>
|
||||
<contact:fax>{$item['contact:fax']}</contact:fax>
|
||||
<contact:email>{$item['contact:email']}</contact:email>
|
||||
|
||||
@@ -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}
|
||||
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@
|
||||
</th>
|
||||
</tr>
|
||||
{if isNonnull($item['domain:ns'] and isNonnull($item['domain:ns']['domain:hostObj']))}
|
||||
{foreach $hostObj in $item['domain:ns']['domain:hostObj']}
|
||||
{for $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}
|
||||
{/foreach}
|
||||
{/for}
|
||||
{/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) */
|
||||
{foreach $contact in $contacts}
|
||||
{for $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}
|
||||
{/foreach}
|
||||
{/for}
|
||||
{/template}
|
||||
|
||||
|
||||
|
||||
@@ -32,18 +32,18 @@
|
||||
{/if}
|
||||
{if isNonnull($item['domain:ns'])}
|
||||
<domain:ns>
|
||||
{foreach $hostObj in $item['domain:ns']['domain:hostObj']}
|
||||
{for $hostObj in $item['domain:ns']['domain:hostObj']}
|
||||
<domain:hostObj>{$hostObj.value}</domain:hostObj>
|
||||
{/foreach}
|
||||
{/for}
|
||||
</domain:ns>
|
||||
{/if}
|
||||
{if isNonnull($item['domain:registrant'])}
|
||||
<domain:registrant>{$item['domain:registrant']}</domain:registrant>
|
||||
{/if}
|
||||
{if isNonnull($item['domain:contact'])}
|
||||
{foreach $contact in $item['domain:contact']}
|
||||
{for $contact in $item['domain:contact']}
|
||||
<domain:contact type="{$contact['@type']}">{$contact.value}</domain:contact>
|
||||
{/foreach}
|
||||
{/for}
|
||||
{/if}
|
||||
<domain:authInfo>
|
||||
<domain:pw>{$item['domain:authInfo']['domain:pw']}</domain:pw>
|
||||
@@ -128,15 +128,15 @@
|
||||
<{$tagName}>
|
||||
{if isNonnull($hosts)}
|
||||
<domain:ns>
|
||||
{foreach $host in $hosts}
|
||||
{for $host in $hosts}
|
||||
<domain:hostObj>{$host.value}</domain:hostObj>
|
||||
{/foreach}
|
||||
{/for}
|
||||
</domain:ns>
|
||||
{/if}
|
||||
{if isNonnull($contacts)}
|
||||
{foreach $contact in $contacts}
|
||||
{for $contact in $contacts}
|
||||
<domain:contact type="{$contact['@type']}">{$contact.value}</domain:contact>
|
||||
{/foreach}
|
||||
{/for}
|
||||
{/if}
|
||||
</{$tagName}>
|
||||
{/template}
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
</th>
|
||||
</tr>
|
||||
{if isNonnull($item['host:addr'])}
|
||||
{foreach $addr in $item['host:addr']}
|
||||
{for $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}
|
||||
{/foreach}
|
||||
{/for}
|
||||
{/if}
|
||||
<tr id="domain-host-addrs-footer"></tr>
|
||||
</table>
|
||||
|
||||
@@ -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'])}
|
||||
{foreach $addr in $item['host:addr']}
|
||||
{for $addr in $item['host:addr']}
|
||||
{let $type: strContains($addr['value'], ':') ? 'v6' : 'v4' /}
|
||||
<host:addr ip="{$type}">{$addr['value']}</host:addr>
|
||||
{/foreach}
|
||||
{/for}
|
||||
{/if}
|
||||
</host:create>
|
||||
</create>
|
||||
@@ -101,10 +101,10 @@
|
||||
{let $tagName: $isAdd ? 'host:add' : 'host:rem' /}
|
||||
{if length($addrs) > 0}
|
||||
<{$tagName}>
|
||||
{foreach $addr in $addrs}
|
||||
{for $addr in $addrs}
|
||||
{let $type: strContains($addr, ':') ? 'v6' : 'v4' /}
|
||||
<host:addr ip="{$type}">{$addr}</host:addr>
|
||||
{/foreach}
|
||||
{/for}
|
||||
</{$tagName}>
|
||||
{/if}
|
||||
{/template}
|
||||
|
||||
@@ -47,12 +47,12 @@
|
||||
<td class="{css('setting')}">
|
||||
<div class="{css('info')} {css('summary')}">
|
||||
<div id="ips">
|
||||
{foreach $ip in $ipAddressWhitelist}
|
||||
{for $ip in $ipAddressWhitelist}
|
||||
{call .ip}
|
||||
{param name: 'ipAddressWhitelist[' + index($ip) + ']' /}
|
||||
{param ip: $ip /}
|
||||
{/call}
|
||||
{/foreach}
|
||||
{/for}
|
||||
</div>
|
||||
<div class="{css('hidden')}">
|
||||
<input id="newIp" value="" placeholder="Enter IP address..."/>
|
||||
|
||||
@@ -149,13 +149,13 @@
|
||||
{@param? state: string}
|
||||
{@param? zip: string}
|
||||
{@param countryCode: string}
|
||||
{foreach $line in $street}
|
||||
{for $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>
|
||||
{/foreach}
|
||||
{/for}
|
||||
<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}">
|
||||
|
||||
Reference in New Issue
Block a user