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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

template.ParseGlob() 可以解析子目錄中的模板嗎?

template.ParseGlob() 可以解析子目錄中的模板嗎?

Go
牛魔王的故事 2021-11-01 17:12:25
為了清理模板文件夾,我想將常用模板保存在子文件夾中。目前我有以下文件結(jié)構(gòu):main.gotemplates/index.tpl            # Main template for the main pagetemplates/includes/head.tpltemplates/includes/footer.tplhead.tpl并且footer.tpl將在被調(diào)用index.tpl,它看起來像這樣:{{ template "head" . }}    <h1>My content</h1>{{ template "footer" .}}此外,文件使用template.ParseGlob(). 這是摘錄自main.go:var views = template.Must(template.ParseGlob("src/templates/**/*"))func Render(rw http.ResponseWriter, temp string, data interface{}) {    err := views.ExecuteTemplate(rw, temp, data)    if err != nil {        http.Error(rw, err.Error(), http.StatusInternalServerError)    }}func Index(rw http.ResponseWriter, req *http.Request) {    Render(rw, "index.tpl", nil)}每次打開瀏覽器時(shí),都會(huì)收到以下錯(cuò)誤消息:html/template: "index.tpl" is undefined.是否有可能index.tpl被這種 glob 模式忽略?我發(fā)現(xiàn)了這個(gè)類似的問題,但答案只是一個(gè)解決方法。
查看完整描述

2 回答

  • 2 回答
  • 0 關(guān)注
  • 199 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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