第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

轉(zhuǎn)義 ' 到 ' 在 golang html 模板中

轉(zhuǎn)義 ' 到 ' 在 golang html 模板中

Go
胡說叔叔 2021-09-10 17:04:21
如何防止轉(zhuǎn)義'到&#39;html 模板:package mainimport (    "html/template"    "os")const tmpl = `<html>    <head>        <title>{{.Title}}</title>    </head></html>`func main() {    t := template.Must(template.New("ex").Parse(tmpl))    v := map[string]interface{}{        "Title": template.HTML("Hello World'"),    }    t.Execute(os.Stdout, v)}它輸出:<html>    <head>        <title>Hello World&#39;</title>    </head></html>期望的輸出:<html>    <head>        <title>Hello World'</title>    </head></html>
查看完整描述

1 回答

?
交互式愛情

TA貢獻1712條經(jīng)驗 獲得超3個贊

@dyoo 已經(jīng)清楚地解釋了<title>內(nèi)容被視為 RCDATA。執(zhí)行轉(zhuǎn)義的代碼在這里。分支if t == contentTypeHTML是發(fā)生在template.HTML.

如果您確實需要控制源的輸出,請使用text/template并手動進行轉(zhuǎn)義。


查看完整回答
反對 回復(fù) 2021-09-10
  • 1 回答
  • 0 關(guān)注
  • 212 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號