Martini 渲染在页面上显示 {{ yield }}

Martini render shows {{ yield }} on page

我尝试用马提尼渲染我的页面 layout.html

<!DOCTYPE html>
<html lang="en">
    <head>...</head>
    <header>...</header>
    {{ yield }}
    <footer>...</footer>
</html>

index.html

<main>
    <h1>Hello</h1>
</main>

渲染选项:

m.Use(render.Renderer(render.Options{
        Directory:  "templates",                
        Layout:     "layout", 
        Extensions: []string{".tmpl", ".html"},
        Delims:     render.Delims{"{[{", "}]}"}, 
        Charset:    "UTF-8",  
        IndentJSON: true, 
}))

尝试显示页面:

rnd.HTML(200, "edit", nil)

运行 应用并查看我的页面:

来自 layout.html 的所有代码都正常处理,但 {{ yield }} 字符串保持不变。

您将分隔符设置为“{[{”和“}]}”,但随后使用了“{{”和“}}”。

使用 Delims: render.Delims{"{{", "}}"}, 或更改模板以使用 {[{ yield }]}