## 命名
一般来说为了能够快速分辨出哪个模板是嵌套的模板,会在模板的文件名加上下划线,比如"_form.html"。
```
// templates/users/new.html
Create New User
<%= partial("users/form.html") %>
```
```
// templates/users/_form.html
```
```
// output
Edit Mark Bates (1)
```
## 本地变量
有时候,如果一个子模板被多处调用的时候,可能变量名就不一样,怎办呢?
```
// actions/users.go
func UsersIndex(c buffalo.Context) error {
c.Set("users", []string{"John Lennon", "Paul McCartney", "George Harrison", "Ringo Starr"})
return c.Render(200, r.HTML("users/index.html"))
}
```
```
// templates/users/index.html
All Users
<%= for (u) in users { %>
<%= partial("users/user.html", {user: u}) %>
<% } %>
```
```
// templates/users/_user.html
<%= user.Name %>
```
主要就在 partial("users/user.html", {user: u}) 第二个参数。