## Layout 設計
* * #### 你的整個系統有些是固定的,比如頂部和底部,只會變中間的部分
* #### 使用:
~~~
controller中:
this.Layout = "base.html"
this.TplName = "test_layout.html"
?
base.html中:
?
{{.LayoutContent}} ? 必須設置這個變量,變量名不能變
~~~
* #### 也可以這樣使用
~~~
layout.html中:
{{template "header.html" .}}
Logic code
{{template "footer.html" .}}
~~~
## LayoutSection
~~~
controller中:
this.Layout = "layout_blog.html"
this.TplName = "blogs/index.html"
this.LayoutSections = make(map[string]string) ? ? ? // map類型,key--value
this.LayoutSections["HtmlHead"] = "blogs/html_head.html"
this.LayoutSections["Scripts"] = "blogs/scripts.html"
?
?
layout_blog.html中:
<!DOCTYPE html>
<html>
<head>
? ? <title>Lin Li</title>
? ? <meta name="viewport" content="width=device-width, initial-scale=1.0">
? ? <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
? ? <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
? ? <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap-theme.min.css">
? ? {{.HtmlHead}}
</head>
<body>
?
? ? <div class="container">
? ? ? ? {{.LayoutContent}}
? ? </div>
? ? <div>
? ? ? ? {{.SideBar}}
? ? </div>
? ? <script type="text/javascript" src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
? ? <script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
? ? {{.Scripts}}
</body>
</html>
?
?
html_head.html中:
<style>
? ? h1 {
? ? ? color: red;
? ? }
</style>
?
scripts.html中:
<script type="text/javascript">
? $(document).ready(function() {
? ? ? // bla bla bla
? });
</script>
~~~
##
- go環境搭建
- 解決go get網絡慢的問題
- beego的安裝
- bee的安裝
- 編輯器
- go module
- 配置文件詳解
- 配置文件其他說明
- 路由方法
- 路由
- 數據校驗
- 校驗函數
- 頁面跳轉
- 獲取前端數據
- json文件的獲取
- xsrf的用法
- xsrf的防護
- srfs和json的搭配
- flash的用法
- 過濾器
- url反轉
- 各類數據的處理
- 模板函數
- 內置模板函數
- 自定義模板函數
- 模板
- 模板處理
- 模板渲染
- 視圖文件的處理
- 靜態文件
- 請求方式判斷
- 驗證碼
- 另一種方法
- 分頁類
- session
- 登錄判斷
- orm模塊
- 使用方法
- mysql的安裝
- 安裝orm及驅動
- 建立模型
- 自定義模型
- 增刪改查
- 高級查詢
- 常見問題匯總
- 代碼收藏
- 打包部署
- go build打包
- utils收藏
- 新goer容易犯的錯
- 字符串操作