Skip to content
This repository has been archived by the owner on Feb 21, 2018. It is now read-only.
/ go-tmplbox Public archive

[MOVED] See github.com/lestrrat-go/tmplbox

License

Notifications You must be signed in to change notification settings

lestrrat/go-tmplbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-tmplbox

Build Status

GoDoc

Yet Another (text|html)/template wrapper

WARNING

This repository has been moved to github.com/lestrrat-go/tmplbox. This repository exists so that libraries pointing to this URL will keep functioning, but this repository will NOT be updated in the future. Please use the new import path.

SYNOPSIS

<!-- base.html -->
{{ define "root" }}
<html>
<body>
{{ block "content" }}{{ end }}
</body>
</html>
{{ end }}
<!-- index.html -->
{{ define "content" }}Hello, World!{{ end }}
// assuming you're using go-bindata's Asset function to
// retrieve template sources here.
var box := tmplbox.New(tmplbox.AssetSourceFunc(Asset))

func indexHandler(w http.ResponseWriter, r *http.Response) {
    // Assuming you have a dependency between index.html and
    // base.html (see above), GetOrCompose will automatically
    // compile and merge all of the specified templates.
    t, _ := box.GetOrCompose("index.html", "base.html")

    // Will output 
    // <!-- base.html -->
    // <html>
    // <body>
    // Hello, World!
    // </body>
    // </html>
    t.ExecuteTemplate(w, "root", nil)
}

FEATURES

  • Plays well with go-bindata
  • Easy to setup template dependency to emulate "extends", without another big library

About

[MOVED] See github.com/lestrrat-go/tmplbox

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages