/* * Copyright 2018 Foolin. All rights reserved. * * Use of this source code is governed by a MIT style * license that can be found in the LICENSE file. * */ package main import ( "github.com/foolin/goview/supports/ginview" "github.com/gin-gonic/gin" "net/http" ) func main() { router := gin.Default() //new template engine router.HTMLRender = ginview.Default() router.GET("/", func(ctx *gin.Context) { //render with master ctx.HTML(http.StatusOK, "index", gin.H{ "title": "Index title!", "add": func(a int, b int) int { return a + b }, }) }) router.GET("/page", func(ctx *gin.Context) { //render only file, must full name with extension ctx.HTML(http.StatusOK, "page.html", gin.H{"title": "Page file title!!"}) }) router.Run(":9090") }