Go 语言模板引擎 gotpl

码农软件 · 软件分类 · 模板引擎 · 2019-08-23 06:44:52

软件介绍

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

LICENSE? Well, WTFPL.

本文地址:https://codercto.com/soft/d/12967.html

Beautiful Code

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》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具