如何告诉Sublime Text在HTML中突出显示Go代码?

huangapple go评论92阅读模式
英文:

How do I tell Sublime Text to highlight the Go code inside my HTML?

问题

Sublime Text可以高亮显示HTML,也可以高亮显示Go代码。我想告诉Sublime Text 3,在我的HTML中,将{{}}之间的Go代码以Go语法高亮显示,而不是作为纯文本显示。

肯定有一种方法可以将两者结合起来。我以为Package Control上的某个golang包会解决这个问题,但我还没有找到一个像GitHub的Atom编辑器默认提供的_HTML (Go)_语法那样的包。

英文:

Sublime Text can highlight HTML. It can highlight Go. I would like to tell Sublime Text 3 to highlight the Go code in between the {{ and }} markers in my HTML to highlight in Go rather than as plain text.

There must be some way to combine the two. I thought surely one of the golang packages on Package Control would address this but I haven't found one that offers an HTML (Go) syntax like GitHub's Atom editor does by default.

答案1

得分: 2

默认的高亮显示包无法正确地高亮显示您的模板。您需要安装Package Control,然后安装GoSublime

完成后,打开您的模板文件。然后点击View > Syntax > GoSublime > GoSublime: HTML。

现在,{{define "foo"}}{{end}}应该以Go语言高亮显示,<p>foo</p>应该以HTML语言高亮显示。

英文:

The default highlighting packages will not correctly highlight your templates. You'll need to install Package Control and then install GoSublime.

Once you've done that, open your template file. Then click View > Syntax > GoSublime > GoSublime: HTML.

You should now have {{define &quot;foo&quot;}}{{end}} highlighted as Go and &lt;p&gt;foo&lt;/p&gt; highlighted as HTML.

huangapple
  • 本文由 发表于 2015年12月12日 06:17:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/34233453.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定