亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

text/html 模板包中的“范圍”操作和“管道”說明。

text/html 模板包中的“范圍”操作和“管道”說明。

Go
慕容3067478 2021-09-10 21:19:09
我嘗試在 text/html 模板包中獲得一些優點。我已經從 golang 站點閱讀了它的文檔。很難理解 . (點)在一般情況下,在一定的時間范圍內動作?!肮艿馈本烤故鞘裁匆馑?,可能因為我的英語不是母語而難以理解):{{pipeline}}The default textual representation of the value of the pipelineis copied to the output.讓我們考慮一個例子:    data := map[string]interface{}{        "struct": &Order{            ID:     1,            CustID: 2,            Total:  3.65,            Name: "Something",        },        "name1":  "Timur",        "name2": "Renat",    }    t.ExecuteTemplate(rw, "index", data)這是“索引”:{{define "index"}}    {{range $x := .}}        {{.}}        <b>{{$x}}</b><br>        <i>{{$.struct.ID}}</i><br>        <br>        # the lines below don't work and break the loop        # {{.ID}}        # or        # {{.struct.ID}}        # what if I want here another range loop that handles "struct" members        # when I reach "struct" field in the data variable or just do nothing        # and just continue the loop?     {{end}}{{end}}輸出:帖木兒帖木兒1長Renat長Renat1{1 2 3.65 某事}{1 2 3.65 某事}1
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 183 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號