render

package module
v0.0.0-...-47bd199 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2015 License: MIT Imports: 4 Imported by: 0

README

gin-pongo2

pongo2 middleware for Gin framework.

##Example:

package main

import (
    "os"

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

func main() {
    switch os.Getenv("MODE") {
    case "RELEASE":
        gin.SetMode(gin.ReleaseMode)

    case "DEBUG":
        gin.SetMode(gin.DebugMode)

    case "TEST":
        gin.SetMode(gin.TestMode)

    default:
        gin.SetMode(gin.ReleaseMode)
    }

    router := gin.New()
    router.Use(gin.Recovery())

    if gin.IsDebugging() {
        router.HTMLRender = render.NewDebug("resources")
    } else {
        router.HTMLRender = render.NewProduction("resources")
    }

    router.Static("/static", "resources/static")
    router.GET("/", func(c *gin.Context) {
        c.HTML(http.StatusOK, "index.tpl", render.Context{"title": "Gin-pongo2!"})
    })

    router.Run(":3000")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context pongo2.Context

type Pongo

type Pongo struct {
	Template *pongo2.Template
	Name     string
	Data     interface{}
}

func (Pongo) Render

func (p Pongo) Render(w http.ResponseWriter) error

type PongoDebug

type PongoDebug struct {
	Path string
}

func NewDebug

func NewDebug(path string) *PongoDebug

func (PongoDebug) Instance

func (p PongoDebug) Instance(name string, data interface{}) render.Render

type PongoProduction

type PongoProduction struct {
	Templates map[string]*pongo2.Template
	Path      string
}

func NewProduction

func NewProduction(path string) *PongoProduction

func (PongoProduction) Instance

func (p PongoProduction) Instance(name string, data interface{}) render.Render

Jump to

Keyboard shortcuts

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