package
0.3.0
Repository: https://github.com/foolin/goview.git
Documentation: pkg.go.dev

# README

EchoView

GoDoc Widget

goview support for echo template v4 version.

Install


go get -u github.com/foolin/goview-v4

go get -u github.com/foolin/goview/supports/echoview-v4

Example


package main

import (
	"github.com/foolin/goview/supports/echoview"
	"github.com/labstack/echo"
	"github.com/labstack/echo/middleware"
	"net/http"
)

func main() {

	// Echo instance
	e := echo.New()

	// Middleware
	e.Use(middleware.Logger())
	e.Use(middleware.Recover())

	//Set Renderer
	e.Renderer = echoview.Default()

	// Routes
	e.GET("/", func(c echo.Context) error {
		//render with master
		return c.Render(http.StatusOK, "index", echo.Map{
			"title": "Index title!",
			"add": func(a int, b int) int {
				return a + b
			},
		})
	})

	e.GET("/page", func(c echo.Context) error {
		//render only file, must full name with extension
		return c.Render(http.StatusOK, "page.html", echo.Map{"title": "Page file title!!"})
	})

	// Start server
	e.Logger.Fatal(e.Start(":9090"))
}

Project structure:

|-- app/views/
    |--- index.html          
    |--- page.html
    |-- layouts/
        |--- footer.html
        |--- master.html
    

See in "examples/basic" folder

Echo example

More examples

See _examples/ for a variety of examples.

# Functions

Default new default config view engine.
Middleware echo middleware wrapper.
New new view engine.
NewMiddleware echo middleware for func `echoview.Render()`.
Render html render for template You should use helper func `Middleware()` to set the supplied TemplateEngine and make `Render()` work validly.
Wrap wrap view engine for goview.ViewEngine.

# Structs

ViewEngine view engine for echo.