Back to godoc.org
github.com/h3poteto/pongo2echo

Package pongo2echo

v0.1.0
Latest Go to latest

The latest major version is .

Published: Nov 3, 2019 | License: MIT | Module: github.com/h3poteto/pongo2echo

Overview

Package pongo2echo provides renderer for labstack's echo framework.

Usage:

import "github.com/h3poteto/pongo2echo"

You can set Pongo2Echo struct to echo.Renderer. For example:

render := pongo2echo.NewRenderer()
render.RegisterFilter("customFilter", customFilerFunc)
render.AddDirectory("server/templates")

e := echo.New()
e.Renderer = render

Then, you can use pongo2 in echo handler functions.

func Index(c echo.Context) error {
    // index.html.tpl is located in server/templates/index.html.tpl
    return c.Render(http.StatusOK, "index.html.tpl", map[string]interface{}{"title": "Index"})
}

Index

type ContextProcessorFunc

type ContextProcessorFunc func(echoCtx echo.Context, pongoCtx pongo2.Context)

ContextProcessorFunc signature.

type Pongo2Echo

type Pongo2Echo struct {
	// contains filtered or unexported fields
}

Pongo2Echo implements custom pongo2 rendering engine for echo.

func NewRenderer

func NewRenderer() *Pongo2Echo

NewRenderer creates a new Pongo2Echo struct.

func (*Pongo2Echo) Abs

func (p *Pongo2Echo) Abs(base, name string) string

Abs returns absolute path to file requested. Search path is configured in AddDirectory method. And default directory is "./templates".

func (*Pongo2Echo) AddDirectory

func (p *Pongo2Echo) AddDirectory(dir string)

AddDirectory adds a directory to the list of directories searched for templates. Default directory is "./templates".

func (*Pongo2Echo) Get

func (p *Pongo2Echo) Get(path string) (io.Reader, error)

Get reads the path's content from your local filesystem.

func (*Pongo2Echo) RegisterFilter

func (p *Pongo2Echo) RegisterFilter(name string, fn pongo2.FilterFunction)

RegisterFilter registers a custom filter. It calls pongo2.RegisterFilter method.

func (*Pongo2Echo) RegisterTag

func (p *Pongo2Echo) RegisterTag(name string, parserFunc pongo2.TagParser)

RegisterTag registers a custom tag. It calls pongo2.RegisterTag method.

func (*Pongo2Echo) Render

func (p *Pongo2Echo) Render(w io.Writer, name string, data interface{}, c echo.Context) error

Render renders the view. Many other times, this is called in your echo handler functions.

func (*Pongo2Echo) SetDebug

func (p *Pongo2Echo) SetDebug(v bool)

SetDebug sets debug mode to the template set. See pongo2.TemplateSet.Debug for more information.

func (*Pongo2Echo) UseContextProcessor

func (p *Pongo2Echo) UseContextProcessor(processor ContextProcessorFunc)

UseContextProcessor adds context processor to the pipeline.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier