A Django-syntax templating engine for Go with advanced expressions, macros, and sandboxing.
pongo2 is a templating engine for the Go programming language that implements a syntax and feature set compatible with Django templates. It allows developers to generate dynamic HTML, text, or other documents using familiar template tags, filters, and expressions. The project solves the need for a powerful, expressive templating system in Go that balances developer familiarity with Go's performance and safety features.
Go developers building web applications, CLI tools, or any system requiring dynamic text generation who prefer or are familiar with Django-style template syntax. It's particularly useful for teams migrating from Django/Python to Go or those wanting consistent templating across stacks.
Developers choose pongo2 because it brings the mature, expressive templating patterns from Django to Go with additional features like advanced C-like expressions, a macro system, and built-in sandboxing for security. It offers a clean, extensible API for custom filters and tags while maintaining high performance.
Django-syntax like template-engine for Go
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Implements Django-like tags and filters, allowing developers with Python/Django background to quickly start templating in Go, as shown in the comprehensive example template.
Supports C-like expressions and complex function calls within templates, enabling sophisticated logic without custom backend code, detailed in the expression tests.
Includes autoescaping, sandboxing with directory restrictions, and banned tags/filters, making it safe for executing untrusted templates, as per the security documentation.
Provides a straightforward API to register custom filters and tags with argument parsing, documented in the custom extensions guide.
Critical filters like 'date' and 'time' use Go's format instead of Django's, requiring template adjustments for teams migrating from Django, as noted in the caveats section.
Essential filters such as markdown are not built-in and require the separate pongo2-addons repository, adding complexity to the setup.
While integrations exist for popular frameworks, using pongo2 with less common or new Go web frameworks may necessitate custom middleware development.
The project is on version v7, indicating potential breaking changes in updates that could require template or code modifications, as suggested by the versioning.