Skip to content

go-baa/render

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

render

a template engine better than default render of baa.

Features

  • template collector, let you can include an other template in template.
  • template cache, cache template file in memory, detect file change and rebuild cache.
  • custom template dir, extensions and functions.

Getting Started

package main

import (
    "github.com/go-baa/baa"
    "github.com/go-baa/render"
)

func main() {
    // new app
    app := baa.New()
    
    // register render
    // render is template DI for baa, must this name.
    app.SetDI("render", render.New(render.Options{
		Baa:        app,
		Root:       "templates/",
		Extensions: []string{".html", ".tmpl"},
	}))
    
    // router
    app.Get("/", func(c *baa.Context) {
        c.HTML(200, "index")
    })
    
    // run app
    app.Run(":1323")
}

you should first have a dir named templates in your application root and a template file named index.html in template dir.

About

baa module providers a template engine.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published