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

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

html/模板:“布局”未定義

html/模板:“布局”未定義

Go
阿晨1998 2021-09-10 09:56:31
我嘗試將馬提尼框架與布局模板一起使用:package mainimport (    "github.com/go-martini/martini"    "github.com/martini-contrib/render")func main() {    m := martini.Classic()    m.Use(render.Renderer(render.Options{Directory: "./templates",        Layout:     "layout",        Extensions: []string{".tmpl"},    }))    m.Get("/", func(r render.Render) {        r.HTML(200, "mainPage", map[string]interface{}{"Title": "some title", "H1": "some h1"})    })    m.Run()}在與此main.go 文件相同的文件夾中,我得到了templates包含layout.tmpl文件的文件夾:<html xmlns="http://www.w3.org/1999/xhtml"></html><head></head><body>      <div id='left'>        {{template "left" .}}    </div>    <div id='right'>        {{template "right" .}}    </div></body>和mainPage.tmpl文件:{{define "left"}}  left content{{end}}{{define "right"}}    right content{{end}}當(dāng)我http://localhost:3000/在瀏覽器中打開時,我看到錯誤: html/template: "layout" is undefined
查看完整描述

2 回答

?
慕哥6287543

TA貢獻(xiàn)1831條經(jīng)驗 獲得超10個贊

我的問題是我go從隨機(jī)目錄運(yùn)行文件。為了解決它,我將目錄 ( cd)更改為templates文件夾的父級。


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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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