-
It is no longer possible to create
Context
objects. Instead, you can pass a dictionary directly to aTemplate
srender
method.- try template.render(Context(dictionary: ["name": "Kyle"])) + try template.render(["name": "Kyle"])
-
Template loader are no longer passed into a
Context
, instead you will need to pass theLoader
to anEnvironment
and create a template from theEnvironment
.let loader = FileSystemLoader(paths: ["templates/"]) - let template = loader.loadTemplate(name: "index.html") - try template.render(Context(dictionary: ["loader": loader])) + let environment = Environment(loader: loader) + try environment.renderTemplate(name: "index.html")
-
Loader
s will now throw aTemplateDoesNotExist
error when a template is not found. -
Namespace
has been removed and replaced by extensions. You can create an extension including any custom template tags and filters. A collection of extensions can be passed to anEnvironment
.
-
Environment
is a new way to load templates. You can configure an environment with custom template filters, tags and loaders and then create a template from an environment.Environment also provides a convenience method to render a template directly.
-
FileSystemLoader
will now ensure that template paths are within the base path. Any template names that try to escape the base path will raise aSuspiciousFileOperation
error. -
New
{% filter %}
tag allowing you to perform a filter across the contents of a block.{% filter lowercase %} This Text Will Be Lowercased. {% endfilter %}
-
You can now use
{{ block.super }}
to render a super block from another{% block %}
. -
Environment
allows you to provide a customTemplate
subclass, allowing new template to use a specific subclass. -
If expressions may now contain filters on variables. For example
{% if name|uppercase == "TEST" %}
is now supported.
-
Template
initialisers have been deprecated in favour of using a template loader such asFileSystemLoader
inside anEnvironment
. -
The use of whitespace inside variable filter expression is now deprecated.
- {{ name | uppercase }} + {{ name|uppercase }}
- Restores compatibility with ARM based platforms such as iOS. Stencil 0.7
introduced compilation errors due to using the
Float80
type which is not available.
- Fixes an issue where using
{% if %}
statements which use operators would throw a syntax error.
-
TemplateLoader
has been renamed toFileSystemLoader
. TheloadTemplate(s)
methods are now throwing and now take labels for thename
andnames
arguments. -
Many internal classes are no longer public. Some APIs were previously accessible due to earlier versions of Swift requiring the types to be public to be able to test. Now we have access to
@testable
these can correctly be private. -
{% ifnot %}
tag is now deprecated, please use{% if not %}
instead.
-
Variable lookup now supports introspection of Swift types. You can now lookup values of Swift structures and classes inside a Context.
-
If tags can now use prefix and infix operators such as
not
,and
,or
,==
,!=
,>
,>=
,<
and<=
.{% if one or two and not three %}
-
You may now register custom template filters which make use of arguments.
-
There is now a
default
filter.Hello {{ name|default:"World" }}
-
There is now a
join
filter.{{ value|join:", " }}
-
{% for %}
tag now supports filters.{% for user in non_admins|default:admins %} {{ user }} {% endfor %}
-
Variables (
{{ variable.5 }}
) that reference an array index at an unknown index will now resolve tonil
instead of causing a crash. #72 -
Templates can now extend templates that extend other templates. #60
-
If comparisons will now treat 0 and below numbers as negative.
- Adds support for Swift 3.0.