cidre-ego privides an easy way to integrate the ego template engine into the cidre webframework.
go get github.com/yuin/cidre-ego
Create ego templates and run the ego command.
<%! func ShowItems(w io.Writer, items []string) error %>
<%% import "strings" %%>
<%% import "github.com/yuin/cidre-ego" %%>
<ul>
<% for _, item := range items { %>
<li><%= item %></li>
<% } %>
</ul>
<% ego.EgoLayout(w, MyLayout) %>
<%! func MyLayout(w io.Writer, contents string) error %>
<html><body>
<%== contents %>
</body></html>
ego templates
Set EgoRenderer for a cidre app
app := cidre.NewApp(appConfig)
app.Renderer = ego.NewEgoRenderer()
items := app.MountPoint("/items/")
items.Get("show_item", ".*", func(w http.ResponseWriter, r *http.Request) {
app.Renderer.Html(w, ShowItems, []string{"a", "b", "c"})
})
MIT
Yusuke Inuzuka