在 Hugo 中使用部分时破折号
Dashes when using partial in Hugo
我正在尝试为 hugo 构建自定义主题。这是我第一次使用 Go,我想知道下面代码中的破折号是什么?
{{- partial "head.html" . -}}
如果需要,这里是整个文件:
<!DOCTYPE html>
<html>
{{- partial "head.html" . -}}
<body>
<div id="content">
{{- block "main" . }}{{- end }}
</div>
{{- partial "footer.html" . -}}
</body>
</html>
破折号是否出于某种原因存在?如果是,我应该何时使用它们?
根据此处的文档:https://gohugo.io/templates/introduction/#whitespace
Go 1.6 包含从 Go 标签的任一侧 trim 白色 space 的功能,方法是在紧邻的旁边添加连字符 (-) 和 space相应的 {{ 或 }} 分隔符。
我正在尝试为 hugo 构建自定义主题。这是我第一次使用 Go,我想知道下面代码中的破折号是什么?
{{- partial "head.html" . -}}
如果需要,这里是整个文件:
<!DOCTYPE html>
<html>
{{- partial "head.html" . -}}
<body>
<div id="content">
{{- block "main" . }}{{- end }}
</div>
{{- partial "footer.html" . -}}
</body>
</html>
破折号是否出于某种原因存在?如果是,我应该何时使用它们?
根据此处的文档:https://gohugo.io/templates/introduction/#whitespace
Go 1.6 包含从 Go 标签的任一侧 trim 白色 space 的功能,方法是在紧邻的旁边添加连字符 (-) 和 space相应的 {{ 或 }} 分隔符。