多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 内置模板函数 * ### dateformat: * #### 实现了时间的格式化,返回字符串 * #### 使用方法 * #### 使用方法 { {dateformat .Time "2006/01/02 15:04:05"} } * #### { {dateformat .Time "2006/01/02 3:04:05 PM"} }。 * #### 设置时间格式比较特殊,需要按如下方式,一定不能变 * #### "2006/01/02 15:04:05" * #### "2006/01/02 3:04:05 PM" * #### 貌似是GO的诞生的时间 * ### date * #### 根据字符串返回时间 * #### 使用方法 { {date .T “Y-m-d H:i:s”} }。 * #### 参数说明: * #### Y - 年,四位数字; 如: "1999" * #### y - 年,二位数字; 如: "99" * #### m - 月份,二位数字,若不足二位则在前面补零; 如: "01" 至 "12" * #### M - 月份,三个英文字母; 如: "Jan" * #### d - 几日,二位数字,若不足二位则前面补零; 如: "01" 至 "31" * #### D - 星期几,三个英文字母; 如: "Fri" * #### H - 24 小时制的小时; 如: "00" 至 "23" * #### h - 12 小时制的小时; 如: "01" 至 "12" * #### i - 分钟; 如: "00" 至 "59" * #### l - 星期几,英文全名; 如: "Friday" * #### s - 秒; 如: "00" 至 "59" * #### S - 字尾加英文序数,二个英文字母; 如: "th","nd" * ### compare * #### 实现了比较两个对象的比较,如果相同返回 true,否者 false,使用方法 { {compare .A .B} }。 * #### { {compare 'a' 97} } * #### { {compare "a" "b"} } * #### compare\_not * #### 和compare相反,不相等返回true,相等返回false * #### { {compare\_not 'a' 97} } * #### not\_nil: * #### 判断是不是为空,如果为空则返回false,不为空返回true * #### not\_null:和not\_nil一样的效果 * #### 判断是不是为空,如果为空则返回false,不为空返回true * ### substr * #### 实现了字符串的截取,使用方法 { {substr .Str 0 30} }。 * #### { {substr "我是中国人" 0 4} } * #### 注意: * #### 左闭右开区间 * ### html2str * #### 实现了把 html 转化为字符串,剔除一些 script、css 之类的元素,返回纯文本信息,使用方法 { {html2str .Htmlinfo} }。 * #### { {html2str "百度"} } * ### str2html * #### 实现了把相应的字符串当作 HTML 来输出,不转义,使用方法 { {str2html .Strhtml} }。 * #### { {html2str "百度"} } * ### htmlquote * #### 实现了基本的 html 字符转义,使用方法 { {htmlquote .quote} }。 * #### 只转义特殊字符,比如 ' ' 等 * ### htmlunquote * #### 实现了基本的反转移字符,使用方法 { {htmlunquote .unquote} }。 * #### 和htmlquote相反 * #### { {htmlunquote "百度"} } * ### ***renderform 看renderform章节*** * #### 根据 StructTag 直接生成对应的表单,使用方法 { {&struct | renderform} }。 * ### assets\_js * #### 为 js 文件生成一个 标签. 使用方法 { {assets\_js src} } * #### { {assets\_js "/static/js/jquery.min.js"} } * #### 效果: * ### assets\_css * #### 为 css 文件生成一个 标签. 使用方法 { {assets\_css src} } * #### { {assets\_css "/static/css/teacher.css"} } * #### 效果: * ### config * #### 获取 AppConfig 的值. 使用方法 { {config configType configKey defaultValue} } . 可选的 configType 有 String, Bool, Int, Int64, Float, DIY * #### { {config "String" "runmode" "dev"} } 一共三个参数 * ### map\_get,和index函数获取map类型数据类似 * #### 获取 map 的值 ~~~ this.Data["m"] = map[string]interface{} {   "a": 1,   "1": map[string]float64{   "c": 4, }, } ​ {{ map_get .m "a" }} 获取controller传递的m的a这个key对应的value这个 ~~~ * ### url\_for * #### { {urlfor "TestController.List"} }