Go template rendering or Node.js template rendering?

polaris · · 435 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I&#39;ve been coding in node.js for over a year but recently I&#39;ve been checking out golang. I&#39;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&#39;re best off using the standard html/template. If you&#39;re fine with compiling ERB style templates (much like EJS in Node.js), there&#39;s <a href="https://github.com/titpetric/egon" rel="nofollow">egon</a> - I added something like comments in my fork, I don&#39;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&#39;m advocating the same as @shovelpost. Don&#39;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&#39;s a &#34;twitter&#34;-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

435 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传