在Github中stars数最多的Go模板引擎库集合

在Go语言世界中,除了标准库自带的html/template包之外,还有种类繁多的第三方模板引擎库,这些库大多来自其他语言的经验继承。

提起Go语言模板引擎,很多人自然会想到pongo2模板引擎,这也是笔者接触最早的Go语言模板引擎,几乎所有的Go主流流行的Web框架都对它提供支持,你甚至在xormplus/xorm这个数据库框架库中也能看到他的身影,它是一个像django语法的Go语言模板引擎,如果你以前做过python开发,那你一定会对它无比亲切。

另一个笔者喜欢的Go语言模板引擎是jet,它功能强大,且高效,性能相当出色。另外一大特点是IDE支持,它有一个IDEA插件可供开发者使用,Github地址:https://github.com/jhsx/GoJetPlugin。这也是目前笔者主要使用的Go语言模板引擎之一(以前还有一些老项目是使用pongo2模板引擎的,另外xormplus/xorm中的sql模板也是采用pongo2)。

还有一个笔者想提及的Go语言模板引擎库是go-template,它更像一个模板引擎适配器,它的最大特色是同时支持standard html/template、amber、django、handlebars、pug(jade)、markdown六种模板引擎。

Go语言模板引擎其实主要分两大类,一类是非预编译生成Go代码的模板引擎(如以上提及的这些),另一类则是预编译生成Go代码的模板引擎,这一类模板引擎由于先天优势,性能将更为出色一些,是否采用这类引擎,要看你项目的需求来权衡。这类引擎的佼佼者是hero,也是一位国人开发的Go语言模板引擎库。

目前笔者使用的Go语言模板引擎主要是pongo2jethero。如果您还有想推荐的Go语言模板引擎库,欢迎留言分享。

下面是我整理的Go语言模板引擎库列表,相信总有一款适合您:)

Project NameStarsForksDescription
pongo21028103Django-syntax like template-engine for Go
mustache853128mustache.go is an implementation of the mustache template language in Go.
hero79539A handy, fast and powerful go template engine.
quicktemplate79448Fast, powerful, yet easy to use template engine for Go. Optimized for speed, zero memory allocations in hot paths.
amber74644Amber is an elegant templating engine for Go Programming Language, inspired from HAML and Jade
ace61632Ace is an HTML template engine for Go. This is inspired by Slim and Jade. This is a refinement of Gold.
gorazor59470GoRazor is the Go port of the razor view engine originated from asp.net in 2011.
jet40022Jet is a template engine developed to be easy to use, powerful, dynamic, yet secure and very fast.
ego32325Ego is an ERb style templating language for Go. It works by transpiling templates into pure Go and including them at compile time. These templates are light wrappers around the Go language itself.
raymond18616Handlebars for golang
fasttemplate14324Simple and fast template engine for Go
soy12018Go implementation for Soy templates (Google Closure templates)
kasia.go705Kasia.go is a Go implementation of the Kasia templating system.
ftmpl491Fast typesafe templating for golang
go-template303The best way to work with different type of Template Engines and Parsers for Go Programming Language
damsel191Markup language featuring html outlining via css-selectors, extensible via pkg html/template and others.
Ego150Embedded Go – a Go-like template language

下面是来自Go Template Benchmark的部分Go语言模板引擎库的性能对比数据

full featured template engines

NameRunsµs/opB/opallocations/op
Ace500,0008.9721,71242
Amber1,000,0005.6281,44038
Golang1,000,0005.3791,36037
Handlebars500,00010.1744,21082
JetHTML3,000,0001.20900
Kasia1,000,0003.3511,18425
Mustache1,000,0003.5441,56828
Pongo21,000,0004.6812,36046
Soy1,000,0003.0671,37625

precompilation to Go code

NameRunsµs/opB/opallocations/op
Ego5,000,0000.793858
Egon3,000,0001.54114912
EgonSlinso20,000,0000.31100
Ftmpl3,000,0001.2981,14112
Gorazor5,000,0001.01461311
Hero30,000,0000.16200
Quicktemplate20,000,0000.28900

10162746_sA3f.jpg

10162748_n41J.jpg

转载于:https://my.oschina.net/u/168737/blog/1533733

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值