2016-05-28 10 views

答えて

3

使用{{range pipeline}} T1 {{else}} T0 {{end}}

{{range pipeline}} T1 {{else}} T0 {{end}} 
     The value of the pipeline must be an array, slice, map, or channel. 
     If the value of the pipeline has length zero, dot is unaffected and 
     T0 is executed; otherwise, dot is set to the successive elements 
     of the array, slice, or map and T1 is executed. 

例:

{{range .Users}} 
... 
{{else}} 
<p>No users</p> 
{{end}} 
+0

.Usersカウントが0より大きい場合どのように私はちょうどチェックだろうか?私はそれがループしないようにしたい。 – Blankman

関連する問題