<p>I've been coding in node.js for over a year but recently I've been checking out golang. I'm used to template rendering using node.js but are there good golang template engines?</p>
<hr/>**评论:**<br/><br/>shovelpost: <pre><p>There is <a href="https://golang.org/pkg/html/template/" rel="nofollow">html/template</a> but why not just keep the frontend on the client with something like Vue, React or Polymer?</p></pre>titpetric: <pre><p>Well, there are a number of template engines, but if you want to stick with Go, you're best off using the standard html/template. If you're fine with compiling ERB style templates (much like EJS in Node.js), there's <a href="https://github.com/titpetric/egon" rel="nofollow">egon</a> - I added something like comments in my fork, I don't remember anymore. If you need raw speed and want to stick with Go syntax in the templates, this is your best bet, but it does require a compile upon changing the template.</p>
<p>Today I'm advocating the same as @shovelpost. Don't use Go for templating if you can, but just to provide the API services. Use Vue/Angular/React/Whatever. For a very small example here's a "twitter"-like page which uses a Go api and a Vue front-end; <a href="https://github.com/titpetric/books/tree/master/12fa-docker-golang/chapter7" rel="nofollow">github book samples page</a>.</p>
<p>Good luck :)</p></pre>Swarengen: <pre><p><a href="http://lmgtfy.com/?q=golang+template+engines" rel="nofollow">http://lmgtfy.com/?q=golang+template+engines</a></p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传