pongo2

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

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

Go to latest
Published: Apr 12, 2016 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

beego-pongo2.v3

A tiny little helper for using Pongo2 (v3) with Beego.

Status: With little tests. IF YOU FIND BUGS, PLS LET ME KNOW.

Documentation: http://godoc.org/github.com/danegigi/beego-pongo2.v3

Based on https://github.com/ipfans/beego-pongo2.v2

Usage

package controllers

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

type MainController struct {
    beego.Controller
}

func (this *MainController) Page1() {
    err := pongo2.Render(this.Ctx, "page.html", pongo2.Context{
        "ints": []int{1, 2, 3, 4, 5},
    })

    if err != nil{
      this.Abort("500")
    }
}

func (this *MainController) Page2(){
  str, err := pongo2.RenderString("page2.html", pongo2.Context{
    "name": "My Name"
  })

  if err != nil{
    this.Abort("500")
  }

  this.Ctx.WriteString(str)
}

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

View Source
var Pango2TemplatesPath string

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

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
⌂ 换网址