Releases: flosch/pongo2
v6.0.0
v6.0.0
- Go 1.18 is now the minimum required Go version.
- Improved block performance (#293).
- Support for variable subscript syntax (for maps/arrays/slices), such as
mymap["foo"]
or
myarray[0]
(#281). - Backwards-incompatible change:
block.Super
won't be escaped anymore by default (#301). nil
is now supported in function calls (#277).
Thanks to all contributors.
v4.0.2
v4.0.1
v4.0.0
Changes in this long awaited release:
Library
- First semver version with Go modules compatibility
- Several bug fixes
- Improved error handling
- Several refactorings to speed up execution and reduce allocations, including support for
io.Writer
inExecute()
functions and short-circuit evaluations in expressions - Add
TemplateSet.FromBytes
- Add
RenderTemplateBytes
- Add
Template.ExecuteWriterUnbuffered
- Add
TemplateLoader
interface and according functions for virtual filesystem support (incl. support for multiple loaders) - Add
pongo2.SetAutoescape
for a global behavior change - Add whitespace control for tags and blocks, supporting
{%-
and-%}
for tags andpongo2.Options
for blocks - Add
pongo2.CleanCache
to remove files from the template cache - Add support for template functions that return an error as the second return value
- Add
Template.ExecuteBlocks
to render supplied list of blocks only
See v3.0...v4.0.0 for a full list of changes.
Thanks to all contributors!
Template Language
- Add support for single quotes in variables, functions and tags
- Add support for
if_exists
-flag ininclude
-tag - Add support for
sorted
-flag infor
-tag with support for maps and arrays/slices - Add
block.Super
support - Add
split
filter
pongo2 v3 released
See this blog post for more about the pongo2 v3 release:
pongo2 v2.1 released along with pongo2 v3
See more in this blog post:
pongo2 v2 released
I'm happy to release the first major update for pongo2: v2. It got a lot of new features and bug fixes. Thanks to all reporters and contributors.
This release is backwards-incompatible to v1 which means chances are you have to adapt your codebase (slightly) in order to use v2. The pongo2 playground already uses pongo v2 (including the new features like sandboxing) and now got the official pongo2-addons
package enabled for testing and playing with pongo2. pongo2-addons
is already ready to use with pongo v2.
To install v2 and get backwards-compatible changes and bugfixes for later versions of the v2 series, use this import path:
Use this import path to stick with the latest development version of pongo2:
New major features
- Template sets: pongo2 allows to group similar kind of templates using a technique called template sets (for example web vs. email templates). Users can apply different configurations and sandbox restrictions (see below) on a specific template set. A default template set is created when pongo2 is imported (this is the one all pongo2-global API functions like
From*
are working on); see theDefaultSet
here. Features of the template sets include:- Debugging: If
Debug
is set to true, logging of specific errors occur tostdout
(you can print out errors as well using the newExecutionContext.Logf
function which will only print out your logging information whenDebug
is true).Debug
has implications on the new template caching function as well (see below). - Globals: It is now possible to provide a global context (in addition to a per-template context) for a template set. It's always possible to override global variables through a per-template context.
- Base directory: The previous behavior of a filename lookup (inside templates, for example when using the
include
,extends
orssi
-tag, or outside templates when calling theFrom*()
-functions) was, in case of a relative path, to lookup the filename relative to the application's directory or, in case of an absolute path, to take this absolute one. It's now possible to change the base lookup directory (for relative paths) by using the new template set functionsSetBaseDirectory()
andBaseDirectory()
. - Sandboxing: To provide more security, pongo2 introduces a per-template-set sandbox. It can prohibit the usage of filters and tags or restrict file accesses (within templates when using a file-sensitive tag/filter like
include
or outside of templates when using a function likeFrom*()
). Use the attributeSandboxDirectories
to provide path patterns supported by http://golang.org/pkg/path/filepath/#Match in order to restrict the access to specifc files or directories. You can limit the tag/filter access by using the two new template set functionsBanFilter
andBanTag
.
- Debugging: If
- Template caching: pongo2 introduces a new API function
FromCache
which behaves likeFromFile
, but includes caching:FromCache
only compiles a template once per template (even if called multiple times) and can be called from multiple Goroutines (it's thread-safe). When debugging is activated (see above), FromCache will re-compile the given template on any request (simplifies development to see live changes). - Macro imports/exports: pongo2 supports now importing and exporting of macros. Exporting is done by appending the
export
keyword to your macro declaration (like this:{% macro my_exported_macro(args1, args2="default string") export %}
). You can import exported macros by using the newimport
tag:{% import "my_file_with_macros.html" my_exported_macro, another_exported_macro as renamed_macro %}
. Macros import macros (chaining macros) is supported. - New pongo2-specific tag
set
: Sets a variable to a given expression like this:{% set my_variable = 5 + 10 / another_var_number %}
New minor features
- Added support for the
reversed
argument for thefor
-tag elif
-tag added (to support multiple cases when using theif
-tag)- It's now possible to replace the behavior of already registered tags and filters through 2 new API-functions:
ReplaceTag
andReplaceFilter
. - It's now possible to mark a
pongo2.Value
assafe
(so theescape
filter won't get applied when outputting the value) using the new API-functionAsSafeValue
. This reduces the necessary to apply thesafe
filter manually, for example when using themarkdown
filter from thepongo2-addons
package. - New
Error
type which returns detailed machine-readable information (including the affected raw template line) about the error occurred and is now much more specific in some cases on which error occurred
Bugfixes and other improvements
- Better UTF-8 handling of filters and tags
- Performance of template execution improved
- Bugfix in handling of the
parsed
argument of thessi
-tag - Bugfix related to the operator associativity
- Better documentation (but still not perfect)
Notable backward-incompatible API-changes (v1 <-> v2):
- The interface type
INodeEvavluator
got replaced byIEvaluator
- Function signature for tag and filter parsing/execution changed (error return type changed to
*Error
).
See the whole changelog here: v1...v2
As always, I'm happy about any feedback!
pongo2 v1.0 (first stable release)
I'm happy to announce pongo2 v1.0, the first stable release.
pongo2 aims to be compatible with Django 1.7 with regards to syntax, filters and tags. In combination with my official package pongo2-addons
pongo2 offers even more filters/tags including humanization and markup features.
All version 1.x releases will remain backwards compatible (only API improvements are possible, but no changes to any existing API functions/symbols). You can use the special import path
gopkg.in/flosch/pongo2.v1
to stick with version 1.x releases in your projects.
List of TODOs which could effect users of version 1.0:
- tag
verbatim
does not take a parameter yet block.super
not supported yetValue.Iterate()
over strings is not utf-8 compatible yet (probably rarely used by users)
Please also have a look on the caveats and on the development status hints when using pongo2.
pongo2 got a playground; feel free to play with it and to try pongo2 out.
I'm always glad about any feedback. I hope you enjoy this release!
Release candidate 1 (RC1) for pongo2 1.0 (first stable release).
I just finished the first release candidate for the first stable pongo2 version (1.0).