Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
Update usage
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Feb 3, 2020
1 parent bd96112 commit c65d212
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ Views is a templates(html/template) manager, it provides the following features
## Usage

```go
// options
opts := []views.Option{
// views.Suffix(".tmpl"), // template suffix, default to .tmpl.
// views.Delims("{{", "}}"), // template delimiters, default to "{{" and "}}".
views.Theme("default"),
views.Layouts("layouts/main", "layouts/header", "layouts/footer"),
// global function map for all templates.
views.FuncMap(template.FuncMap{
"title": strings.Title,
}),
// views.Cache(true),
}
view = views.New("./themes", opts...)
// render template with layouts.
view.Render(w, "site/index", data)
// render tempalte without layouts.
view.RenderPartial(w, "/site/partial")
// options
opts := []views.Option{
// views.Suffix(".tmpl"), // template suffix, default to .tmpl.
// views.Delims("{{", "}}"), // template delimiters, default to "{{" and "}}".
views.Theme("default"),
views.Layouts("layouts/main", "layouts/header", "layouts/footer"),
// global function map for all templates.
views.FuncMap(template.FuncMap{
"title": strings.Title,
}),
// views.Cache(true),
}
view = views.New("./themes", opts...)
// render template with layouts.
view.Render(w, "site/index", data)
// render tempalte without layouts.
view.RenderPartial(w, "/site/partial")
```

Please take a look of the following [example](example):
Expand Down

0 comments on commit c65d212

Please sign in to comment.