Skip to content

Noblefel/lensa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A wrapper around go html/template to skip the tedious parsing part. Not recommended.

go get github.com/Noblefel/lensa

Quick example that writes to standard output (see examples):

func main() {
	render := lensa.Default()
	render.View(os.Stdout, "index", nil)
}

Basic example for web (see examples):

func main() {
	render := lensa.Default()
	mux := http.NewServeMux()

	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		render.View(w, "index", nil)
	})

	mux.HandleFunc("/dashboard", func(w http.ResponseWriter, r *http.Request) {
		render.View(w, "dashboard", nil)
	})

	http.ListenAndServe(":8080", mux)
}

For caching, simply use UseCache function:

	render := lensa.Default()
    render.UseCache() // <-- should be done once after creation

Warning - make sure to separate the templates for pages (like index, dashboard etc) and templates for parts (layout, components) in their own directory.

About

A wrapper around go html/template to skip the tedious parsing part. Not recommended

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages