Skip to content
A template engine which implements a Django-template-like syntax.
Go
Find file
Latest commit 9f6442c Jul 1, 2014 @flosch Update README.md
Failed to load latest commit information.
template_examples Added static-flag for extends/include-tags (see template-tests for us… Sep 8, 2012
.gitignore
.travis.yml Create .travis.yml Jul 1, 2014
LICENSE
README.md
context.go Renamed GoTemplate to Pongo. Aug 22, 2012
doc.go Renamed GoTemplate to Pongo. Aug 22, 2012
expr.go
filters.go Added floatformat filter. Jun 7, 2013
helper.go Renamed GoTemplate to Pongo. Aug 22, 2012
tags.go Go fmt; enhanced init-checks. Oct 15, 2012
template.go Couple of changes: 1) Let the safe filter only apply on strings. 2) F… Sep 10, 2012
template_test.go Added floatformat filter. Jun 7, 2013

README.md

GoDoc Build Status

I deactivated the issue tracker and wiki pages for pongo. pongo won't receive bugfixes anymore. Please consider using the successor pongo2 instead. You can find more information and a migration tutorial on my website.

pongo is a well-tested template engine which implements a Django-template-like syntax.

Please have a look at the test (template_test.go) for examples.

A tiny example (template string)

in := "Hello {{ name|capitalize }}!"
tpl, err := pongo.FromString("mytemplatetest", &in, nil)
if err != nil {
    panic(err)
}
out, err := tpl.Execute(&pongo.Context{"name": "florian"})
if err != nil {
    panic(err)
}
fmt.Println(*out) // Output: Hello Florian!

Example server-usage (template file)

package main

import (
    "github.com/flosch/pongo"
    "net/http"
)

var tplExample = pongo.Must(pongo.FromFile("example.html", nil))

func examplePage(w http.ResponseWriter, r *http.Request) {
    err := tplExample.ExecuteRW(w, &pongo.Context{"query": r.FormValue("query")})
    if err != nil {
        http.Error(w, err.Error(), http.StatusInternalServerError)
    }
}

func main() {
    http.HandleFunc("/", examplePage)
    http.ListenAndServe(":8080", nil)
}

Documentation

See the wiki (work in progress) on GitHub for a documentation/reference:

https://github.com/flosch/pongo/wiki.

While I'm working on the wiki content, GoPkgDoc shows a list of implemented filters/tags and an auto-generated documentation on how to use the simple API:

http://go.pkgdoc.org/github.com/flosch/pongo

It is possible to add your own filters/tags. See the template_test.go for example implementations.

Status

pongo is still in beta and has a very few known bugs (this is why the tests fail).

License

pongo is licensed under the MIT-license (see LICENSE file for more).

Something went wrong with that request. Please try again.