ginpongo2

package module
v0.0.0-...-edb5893 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2015 License: MIT Imports: 3 Imported by: 1

README

ginpongo2

  • The github.com/ngerakines/ginpongo2 package provides a middleware that can be used to render pongo2 templates.
  • This repo uses func FromCache() instead of FromFile() to cache templates rendering result, in order to improve performances. Read the issue for further information.
  • Support Gin 1.0.

Example

To use this, first ensure that the middleware is being referenced by gin using Use. Then inide of your handler, use the context Set methods to set the "template" and "data" variables.

package main

import (
	"github.com/gin-gonic/gin"
	"github.com/ngerakines/ginpongo2"
	"log"
)

func main() {
	r := gin.Default()
	r.Use(ginpongo2.Pongo2())

	r.GET("/", func(c *gin.Context) {
		c.Set("template", "index.html")
		c.Set("data", map[string]interface{}{"message": "Hello World!"})
	})

	e := r.Run(":8080")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pongo2

func Pongo2() gin.HandlerFunc

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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