基本语法

go 统一使用了{{ }}作为左右标签,没有其他的标签符号。

使用 . 来访问当前位置的上下文

使用 $ 来引用当前模板根级的上下文

常用标签

字段
说明
{{.AppName}}
网站名称
{{.Appsite}}
网站域名
{{.AppLogoBlack}}
网站深色LOGO
{{.AppLogoWhite}}
网站浅色LOGO
{{.AppFavicon}}
网站Favicon
{{.AppTongJi}}
网站统计代码
{{.AppIcp}}
网站ICP备案
{{.AppContact}}
网站联系人
{{.AppKeFu}}
网站客服
{{.AppEmail}}
网站邮箱
{{.AppAddress}}
网站地址
{{.AppMpWeiXin}}
公众号
{{.AppWorkTime}}
工作时间
{{.AppItrust}}
iTrust认证ID
{{.ThemeName}}
网站模板名称

模板嵌套

字段
说明
{{template "common_css.html"}}
全局CSS
{{template "common_js.html"}}
全局JS
{{template "header.html"}}
全局头部
{{template "footer.html"}}
全局底部
{{template "right.html"}}
全局右边栏

示例代码

1.导航循环Group为2的分类

{{range $.CateGroup2 }}

{{.url}}{{.name}}

{{end}}

其中CateGroup2对应数据库k2_category表中,group的属性值,只支持1/2。