ginmultitemplate

package module
v1.0.2-0...-e1d361b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2021 License: MIT Imports: 9 Imported by: 0

README

ginmultitemplate

介绍

gin多级目录支持

例子


import (
	"html/template"
	"net/http"
	"testing"
	"time"

	"github.com/gin-gonic/gin"
)

func main() {
	engine := gin.Default()
	// engine.LoadHTMLFiles("templates/1.html", "templates/aa/2.html")
	funcMap := template.FuncMap{
		"date": func() string {
			return time.Now().Format("2006-01-02 15:04:05.00000")
		},
	}
	engine.HTMLRender = LoadTemplateFiles("templates", ".html", funcMap)
	engine.GET("/", func(c *gin.Context) {
		c.HTML(http.StatusOK, "index.html", gin.H{})
	})
	engine.GET("/sub", func(c *gin.Context) {
		c.HTML(http.StatusOK, "sub/sub.html", gin.H{})
	})
	engine.Run()
}

使用说明

import "gitee.com/jalright/ginmultitemplate"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadTemplateFiles

func LoadTemplateFiles(templateDir, stuffix string, funcMap template.FuncMap) multitemplate.Renderer

LoadTemplateFiles 加载模板

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL