英文:
Martini render shows {{ yield }} on page
问题
我尝试在martini中渲染我的页面。
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 }}字符串保持不变。
英文:
I try to render my page in martini
layout.html
<!DOCTYPE html>
<html lang="en">
<head>...</head>
<header>...</header>
{{ yield }}
<footer>...</footer>
</html>
index.html
<main>
<h1>Hello</h1>
</main>
Render options:
m.Use(render.Renderer(render.Options{
Directory: "templates",
Layout: "layout",
Extensions: []string{".tmpl", ".html"},
Delims: render.Delims{"{[{", "}]}"},
Charset: "UTF-8",
IndentJSON: true,
}))
try show page:
rnd.HTML(200, "edit", nil)
run app and see my page:
All code from layout.html is processed normaly, but the {{ yield }} string stays without difference.
答案1
得分: 1
你将分隔符设置为"{[{}]}",但后面使用了"{{}}"。
要么使用Delims: render.Delims{"{{", "}}"},
,要么更改模板以使用"{[{ yield }]}"。
英文:
You set your delimiters to "{[{" and "}]}", but then uses "{{" and "}}".
Either use Delims: render.Delims{"{{", "}}"},
or change your template to use {[{ yield }]}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论