2016-04-27 7 views

答えて

1

Giftはオプションであり、Giftが提供されていない場合、私たちは手紙の中で何かを感謝したくありません。 Giftが提供されている場合は、贈り物に感謝したいと思います。

{{with}}アクションが渡されたパイプラインが空でない場合にのみ、条件付きでその本体を実行します。

{{with pipeline}} T1 {{end}} 
    If the value of the pipeline is empty, no output is generated; 
    otherwise, dot is set to the value of the pipeline and T1 is 
    executed. 

ですから、例えば、これを含んでいます

{{with .Gift -}} 
Thank you for the lovely {{.}}. 
{{end}} 

これがあれば.Giftが空でないことを意味し、出力(手紙)に「ありがとう」文を含める。 .Giftが空の場合、「ありがとう」は省略されます。

関連する問題