- 授权协议: WTFPL
- 开发语言: Google Go
- 操作系统: 跨平台
- 软件首页: https://github.com/codinl/gotpl
- 软件文档: https://github.com/codinl/gotpl
软件介绍
gotpl
go语言模板引擎。基于gorazor开发。
特性
简洁优雅
模板继承
原生go语言
模块,组件
原生go语句
@if .... {
....
}
@if .... {
....
} else {
....
}
@for .... {
}
@{switch .... {
case ....:
<p>...</p>
case 2:
<p>...</p>
default:
<p>...</p>
}
}模板继承(extends,block)
base.tpl :
<html>@block aa {aaaa@block bb {bbb}@block cc {ccc}
}@section Pagination(curPage int)
</html>test_extends_base.tpl :
@block bb { extends bbb
}@block cc { @for i:=0;i<10;i++ {
<p>@i</p>
}
}文件名test_extends_base.tpl,代表test.tpl继承base.tpl。模板继承方式,类似django,通过覆盖block。
模块组件(section)
base.tpl :
<html>...@section Pagination(curPage int) </html>
sections/page.tpl:
@{import (
)
}@section Pagination(curPage int) {
<div>curPage is: @curPage </div>
}section必须放在sections目录下,文件名不限制。
LICENSE
Beautiful Code
Greg Wilson、Andy Oram / O'Reilly Media / 2007-7-6 / GBP 35.99
In this unique work, leading computer scientists discuss how they found unusual, carefully designed solutions to difficult problems. This book lets the reader look over the shoulder of major coding an......一起来看看 《Beautiful Code》 这本书的介绍吧!
