pongo2

package module
v0.0.0-...-3e4fc0a Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2017 License: MIT Imports: 9 Imported by: 1

README

beego-pongo2 v3 version

##download and install go get -u github.com/astaxie/beego

go get -u gopkg.in/flosch/pongo2.v3

go get -u github.com/yansuan/beego-pongo2

#####Latest stable release: v3.0 (go get -u gopkg.in/flosch/pongo2.v3 / v3-branch)

##code

package controllers

import (
    "github.com/astaxie/beego"
    "github.com/yansuan/beego-pongo2"
)

type MainController struct {
    beego.Controller
}

func (this *MainController) Get() {
    pongo2.Render(this.Ctx, "page.html", pongo2.Context{
        "name": "value"},
    })
}

Documentation

Overview

A small library that lets you use Pongo2 with Beego

When Render is called, it will populate the render context with Beego's flash messages. You can also use {% urlfor "MyController.Action" ":key" "value" %} in your templates, and it'll work just like `urlfor` would with `html/template`. It takes one controller argument and zero or more key/value pairs to fill the URL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(beegoCtx *context.Context, tmpl string, ctx Context) error

Render takes a Beego context, template name and a Context (map[string]interface{}). The template is parsed and cached, and gets executed into beegoCtx's ResponseWriter.

Templates are looked up in `templates/` instead of Beego's default `views/` so that Beego doesn't attempt to load and parse our templates with `html/template`.

func RenderString

func RenderString(tmpl string, ctx Context) (string, error)

Same as Render() but returns a string

func SetAssetFS

func SetAssetFS(fs *assetfs.AssetFS)

Types

type Context

type Context map[string]interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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