【发布时间】:2020-06-23 22:06:35
【问题描述】:
我想修剪 Go 模板中的空白。我该怎么做?
例子:
{{ $title = " My Title of the product " }}
// Print the trim string here
<h1>{{ $title }}</h1>
【问题讨论】:
-
"trim whitespace" 通常意味着从字符串的开头和结尾删除空格。字符串的开头或结尾没有空格——即使有,在 HTML 输出中也没有关系,因为多余的空格会被忽略。所以你的问题很不清楚。
-
如果您正在寻找如何删除模板 actions 之间的空白,那么您可以使用
-文档中的 here。
标签: go go-templates