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

Algorithms

Algorithms

Sanjoy Dasgupta、Christos H. Papadimitriou、Umesh Vazirani / McGraw-Hill Education / 2006-10-16 / GBP 30.99

This text, extensively class-tested over a decade at UC Berkeley and UC San Diego, explains the fundamentals of algorithms in a story line that makes the material enjoyable and easy to digest. Emphasi......一起来看看 《Algorithms》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

html转js在线工具
html转js在线工具

html转js在线工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具