Multitemplate

Iris allows unlimited number of registered view engines per Application. Besides that, you can register a view engine per Party or through middleware too!.

  1. // Register a view engine per group of routes.
  2. adminGroup := app.Party("/admin")
  3. adminGroup.RegisterView(iris.Blocks("./views/admin", ".html"))

Through Middleware

  1. func middleware(views iris.ViewEngine) iris.Handler {
  2. return func(ctx iris.Context) {
  3. ctx.ViewEngine(views)
  4. ctx.Next()
  5. }
  6. }

Usage

  1. // Register a view engine on-fly for the current chain of handlers.
  2. views := iris.Blocks("./views/on-fly", ".html")
  3. views.Load()
  4. app.Get("/", setViews(views), onFly)