英文:
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 "foo"}}{{end}}
highlighted as Go and <p>foo</p>
highlighted as HTML.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论