Compare commits

...

2277 Commits
2.2 ... main

Author SHA1 Message Date
David Lord
5ef70112a1
Merge branch 'stable' 2025-06-14 13:34:58 -07:00
David Lord
284501eb0f
remove slsa provenance (#2105) 2025-06-14 13:10:44 -07:00
David Lord
7eb5758063
remove slsa provenance
PyPI and trusted publishing has built-in attestation support now.
2025-06-14 13:08:46 -07:00
David Lord
0514dce509
Merge branch 'stable' 2025-06-12 13:59:39 -07:00
David Lord
ede7905d30
svg logo 2025-06-12 13:58:36 -07:00
David Lord
77092a882a
Merge branch 'stable' 2025-06-11 10:38:29 -07:00
David Lord
0b08e13cac
svg logo (#2102) 2025-06-11 10:37:58 -07:00
David Lord
8ee8f90d67
svg logo 2025-06-11 10:32:48 -07:00
David Lord
10304827e4
update identifier pattern for Python 3.10 (#2099) 2025-05-28 12:14:31 -07:00
David Lord
574565b1ef
update identifier pattern for Python 3.10 2025-05-28 12:10:09 -07:00
David Lord
0547cd6c58
add Python version comment 2025-05-28 12:09:42 -07:00
David Lord
9c11dd65ff
fix typo 2025-05-28 11:44:50 -07:00
David Lord
9e49736ae0
deprecate __version__ (#2098) 2025-05-28 11:43:08 -07:00
David Lord
b7ce542db1
deprecate __version__ 2025-05-28 11:39:42 -07:00
David Lord
dfe82ade3d
bump minimum versions of dependencies (#2097) 2025-05-28 11:20:08 -07:00
David Lord
9508c57faa
bump minimum versions of dependencies 2025-05-28 11:17:40 -07:00
David Lord
49c48a0b31
drop end of life python versions (#2096) 2025-05-28 11:15:29 -07:00
David Lord
ece7c271f3
fix ruff pyupgrade findings 2025-05-28 11:13:57 -07:00
David Lord
0cc6ff9051
drop end of life python versions 2025-05-28 11:13:57 -07:00
David Lord
05f5d74849
Updated dependency management to uv (#2093) 2025-05-28 10:10:27 -07:00
Adam Englander
a3dce7bb64
fix type/lint/format findings 2025-05-28 10:08:39 -07:00
Adam Englander
51dbd8977e
use uv for dependency management
drop python 3.7 and 3.8
move tox config into pyproject
use new license metadata
2025-05-28 10:08:29 -07:00
David Lord
220e67ae99
Merge branch 'stable' 2025-03-05 12:15:40 -08:00
David Lord
01d0bab939
release version 3.1.6 (#2077) 2025-03-05 12:05:21 -08:00
David Lord
15206881c0
release version 3.1.6 2025-03-05 11:51:17 -08:00
David Lord
90457bbf33
Merge commit from fork
attr filter uses env.getattr
2025-03-05 11:49:35 -08:00
David Lord
065334d1ee
attr filter uses env.getattr 2025-03-05 10:08:48 -08:00
David Lord
033c20015c
start version 3.1.6 2025-03-05 09:50:59 -08:00
David Lord
bc68d4efa9
use global contributing guide (#2070) 2025-01-14 13:45:32 -08:00
David Lord
247de5e0c5
use global contributing guide
Remove the per-project files so we don't have to keep them in sync.
GitHub's UI links to everything except the contributing guide, so add a
section about that to the readme.
2025-01-14 13:43:41 -08:00
David Lord
6aeab5d1da
Merge branch 'stable' 2024-12-21 10:47:46 -08:00
David Lord
ab8218c7a1
use project advisory link instead of global 2024-12-21 10:47:08 -08:00
David Lord
b4ffc8ff29
release version 3.1.5 (#2066) 2024-12-21 10:30:50 -08:00
David Lord
877f6e51be
release version 3.1.5 2024-12-21 10:16:13 -08:00
David Lord
8d58859265
remove test pypi 2024-12-21 10:14:49 -08:00
David Lord
eda8fe86fd
update dev dependencies 2024-12-21 10:14:25 -08:00
David Lord
c8fdce1e03
Fix bug involving calling set on a template parameter within all branches of an if block (#1665) 2024-12-21 09:46:55 -08:00
Kevin Brown-Silva
66587ce989
Fix bug where set would sometimes fail within if
There was a bug that came as the result of an early optimization done
within ID tracking that caused loading parameters to fail in a very
specific and rare edge case. That edge case only occurred when the
parameter was being set within all 3 standard branches of an if block,
since the optimization would assume that the parameter was never being
referenced and was only ever being set. This would cause the variable to
be set to undefined.

The fix for this was to remove the optimization and still continue to
load in the parameter even if it is set in all 3 branches.
2024-12-21 09:40:06 -08:00
David Lord
fbc3a696c7
Add support for namespaces in tuple parsing (#1664) 2024-12-20 14:52:51 -08:00
David Lord
b8f4831d41
more comments about nsref assignment
only emit nsref instance check once per ref name
refactor primary name parsing a bit
2024-12-20 14:49:58 -08:00
Kevin Brown-Silva
ee832194cd
Add support for namespaces in tuple assignment
This fixes a bug that existed because namespaces within `{% set %}`
were treated as a special case. This special case had the side-effect
of bypassing the code which allows for tuples to be assigned to.

The solution was to make tuple handling (and by extension, primary token
handling) aware of namespaces so that namespace tokens can be handled
appropriately. This is handled in a backwards-compatible way which
ensures that we do not try to parse namespace tokens when we otherwise
would be expecting to parse out name tokens with attributes.

Namespace instance checks are moved earlier, and deduplicated, so that
all checks are done before the assignment. Otherwise, the check could be
emitted in the middle of the tuple.
2024-12-20 14:09:40 -08:00
David Lord
1d55cddbb2
Triple quotes in docs (#2064) 2024-12-20 08:31:34 -08:00
David Lord
8a8eafc6b9
edit block assignment section 2024-12-20 08:29:04 -08:00
ratchek
d6998ab74e
Make ease of use update to template documentation
Add the phrases 'multiline comment' and 'triple quotes' to docs
in the templates/#block-assignments section. This allows for new
users to find this alternative easily.
2024-12-20 08:19:26 -08:00
David Lord
e7cb37de59
document SandboxedNativeEnvironment pattern (#2063) 2024-12-20 07:58:33 -08:00
David Lord
ae68c961dc
document SandboxedNativeEnvironment pattern 2024-12-20 07:57:11 -08:00
David Lord
028f61da7b
Pass context to test when using select (#1762) 2024-12-19 20:49:09 -08:00
Rens Groothuijsen
d05bd3858c
Pass context when using select 2024-12-19 20:47:24 -08:00
David Lord
7a41ddb915
don't apply urlize to @a@b (#2062) 2024-12-19 20:41:36 -08:00
наб
0cd6948192
don't apply urlize to @a@b 2024-12-19 20:37:58 -08:00
David Lord
106d61cba5
improve annotations for methods returning copies (#1880) 2024-12-19 20:28:13 -08:00
Victor Westerhuis
ded9915fc5
improve annotations for methods returning copies 2024-12-19 20:26:44 -08:00
David Lord
53c75915c9
Improve the PackageLoader error message (#1706) 2024-12-19 20:17:25 -08:00
David Lord
aaa083d265
separate messages, add test 2024-12-19 20:15:10 -08:00
Lily Foote
f54fa113d3
Improve the PackageLoader error message
This exception is raised when the `package_path` directory (default "templates") is not
found, so explain this.
2024-12-19 20:02:32 -08:00
David Lord
58a358f092
FileSystemLoader include paths in error (#1663) 2024-12-19 19:38:22 -08:00
David Lord
227edfd372
clean up message, add test 2024-12-19 19:34:34 -08:00
Yourun-Proger
ed5f76206a
FileSystemLoader includes search paths in error 2024-12-19 19:33:29 -08:00
David Lord
b4b28ec01c
fix default for Environment.overlay(enable_async) (#2061) 2024-12-19 18:23:52 -08:00
SamyCookie
e45bc745a7
Bugfix: wrong default argument for Environment.overlay(enable_async) parameter 2024-12-19 18:22:32 -08:00
David Lord
767b236176
fix f-string syntax error in code generation (#1852) 2024-12-19 18:10:28 -08:00
Sigurd Spieckermann
56a724644b
fix f-string syntax error in code generation 2024-12-19 18:08:42 -08:00
David Lord
48b0687e05
Merge commit from fork
fix format string vulnerability
2024-12-19 14:33:08 -08:00
Lydxn
91a972f580
sandbox indirect calls to str.format 2024-12-19 12:34:27 -08:00
David Lord
0871c71d01
rearrange change entry 2024-12-19 12:07:14 -08:00
David Lord
91e3521173
sandbox disallows clear and pop on mutable sequence (#2033) 2024-12-19 08:36:07 -08:00
Dylan Scott
b512058270
sandbox disallows clear and pop on mutable sequence 2024-12-19 08:33:38 -08:00
David Lord
1dc04bccf9
Fix pickle/copy support for the missing singleton (#2029) 2024-12-19 08:20:38 -08:00
Matt Clay
7232b82462
Fix pickle/copy support for the missing singleton 2024-12-19 08:19:07 -08:00
David Lord
ba8847a466
Preserve __slots__ metadata on Undefined types (#2026) 2024-12-19 08:14:53 -08:00
Matt Davis
d4fb0e8c40
preserve __slots__ on Undefined classes 2024-12-19 08:11:49 -08:00
David Lord
39d9ffff1f
Make compiled output deterministic for tuple unpacking in set tag (#2022) 2024-12-19 08:05:48 -08:00
Anentropic
4936e4d482
make tuple unpacking deterministic in compiler 2024-12-19 08:02:33 -08:00
David Lord
3ef3ba885b
fix how int filter handles scientific notation (#1984) 2024-12-19 07:59:45 -08:00
Felipe Moreno
2eb4542cba
int filter handles OverflowError to handle scientific notation 2024-12-19 07:58:25 -08:00
David Lord
20be10e566
make unique filter async aware (#1782) 2024-12-19 07:26:24 -08:00
Mehdi ABAAKOUK
76af7110ea
make unique filter async-aware 2024-12-19 07:19:13 -08:00
David Lord
a4abbfd753
Use correct concat function for blocks evaluation (#1702) 2024-12-19 07:15:37 -08:00
Martin Krizek
d3a0b1a4ab
use env.concat when calling block reference 2024-12-19 07:12:43 -08:00
David Lord
791dd3b041
Simplify example for ModuleLoader (#1695) 2024-12-18 16:08:33 -08:00
Charles-Axel Dein
955d7daf3d
Simplify example for ModuleLoader
The `ModuleLoader` example seems copy pasted from `ChoiceLoader`. As a result it's not immediately clear how their API differ.
2024-12-18 10:07:18 -08:00
David Lord
13ce60bad8
fix Jinja syntax in example (#2056) 2024-12-18 09:47:24 -08:00
JamesParrott
0c0a3d02d1
fix Jinja syntax in example 2024-12-18 09:44:30 -08:00
David Lord
3d0a7d7b0f
clarify blocks docs (#2060) 2024-12-18 09:39:32 -08:00
David Lord
786d12b529
clarify block outer scope docs 2024-12-18 09:36:11 -08:00
David Lord
c667d56de3
change "per default" to "by default" 2024-12-18 09:33:31 -08:00
David Lord
a12789e7f9
fix list comprehension example (#2017) 2024-12-18 09:21:09 -08:00
Andreas Lindhé
75f0fbf6cb
fix list comprehension example 2024-12-18 09:17:18 -08:00
David Lord
13c42b3aab
Slightly improve clarity of logical bool ops (#1938) 2024-12-18 09:13:55 -08:00
Stephen Rosen
64a6bd1b66
improve clarity of logical bool ops
co-authored-by: David Lord <davidism@gmail.com>
2024-12-18 09:11:57 -08:00
David Lord
619d8eef41
Fix typo on filter name (#1911) 2024-12-18 08:54:02 -08:00
Vitor Buxbaum
7d023e5a86
Fix typo on filter name 2024-12-18 08:52:06 -08:00
David Lord
420082efa5
fix a typo in docs/templates.rst (#1881) 2024-12-18 08:50:01 -08:00
Meng Xiangzhuo
8a90b760a8
fix a typo in docs/templates.rst 2024-12-18 08:48:25 -08:00
David Lord
058e059662
fix boolean error about whitespace control (#1819) 2024-12-18 08:46:48 -08:00
Hugo Vassard
9c3622c1af
fix boolean error about whitespace control 2024-12-18 08:44:58 -08:00
David Lord
da6729990f
Clarify what operations the default "Undefined" supports (#1818) 2024-12-18 08:36:06 -08:00
Clay Sweetser
4e7850ce1b
Clarify what operations the default Undefined supports 2024-12-18 08:34:47 -08:00
David Lord
9849db5215
Add link to MarkupSafe project mentioned in FAQ (#1767) 2024-12-18 08:29:29 -08:00
Matheus Felipe
f502aac8dc
Add link to MarkupSafe in FAQ 2024-12-18 08:27:51 -08:00
Ronan Amicel
d680a95932
Fix nl2br example in documentation (#2054) 2024-12-07 11:04:28 -05:00
David Lord
ada0a9a6fc
update test workflow trigger 2024-10-24 14:16:05 -07:00
David Lord
ee6c734e9b
Merge branch 'stable' 2024-10-24 14:14:07 -07:00
David Lord
d3d0910d8a
update test workflow trigger 2024-10-24 14:13:40 -07:00
David Lord
1e383959f7
update dev dependencies 2024-10-24 14:13:23 -07:00
David Lord
af054f3e48
Improve documentation for initializing the i18n extension (#2023) 2024-09-10 08:43:21 -07:00
Aarni Koskela
a9a0197e3c Improve documentation for initializing the i18n extension
Refs discussion at https://stackoverflow.com/a/78970088
2024-09-10 18:42:07 +03:00
David Lord
eb0df049de
set up pre-commit lite workflow
Committed via https://github.com/asottile/all-repos
2024-09-01 09:04:14 -07:00
David Lord
180816e571
set up pre-commit lite workflow
Committed via https://github.com/asottile/all-repos
2024-09-01 08:48:02 -07:00
David Lord
4c49d2322c
set up pre-commit lite workflow
Committed via https://github.com/asottile/all-repos
2024-09-01 08:32:27 -07:00
David Lord
cd74006a9b
remove pre-commit.ci update 2024-08-23 18:06:04 -07:00
David Lord
9949b49808
Merge branch '3.1.x' 2024-08-23 17:17:11 -07:00
David Lord
3e5b5b2794
refactor 3.7 test pins 2024-08-23 17:15:36 -07:00
David Lord
7f0fc0ad2c
Merge branch '3.1.x' 2024-08-23 16:52:48 -07:00
David Lord
896a1d59b7
remove dependabot 2024-08-23 16:50:05 -07:00
David Lord
3adf44dde2
apply ruff fixes 2024-08-23 16:49:44 -07:00
David Lord
65b27afb61
update dev dependencies 2024-08-23 16:49:33 -07:00
David Lord
a59744f50e
add gha-update 2024-08-23 16:43:52 -07:00
David Lord
b490da6b23
[pre-commit.ci] pre-commit autoupdate (#2012) 2024-08-06 08:30:44 -07:00
pre-commit-ci[bot]
295b284b7c
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.5.0 → v0.5.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.0...v0.5.6)
2024-08-05 23:09:20 +00:00
David Lord
68d75132c4
Bump the python-requirements group in /requirements with 3 updates (#2007) 2024-08-03 07:29:33 -07:00
David Lord
0464cf88a0
Bump the github-actions group with 3 updates (#2008) 2024-08-03 07:28:10 -07:00
dependabot[bot]
293c8abe93
Bump the github-actions group with 3 updates
Bumps the github-actions group with 3 updates: [actions/setup-python](https://github.com/actions/setup-python), [actions/upload-artifact](https://github.com/actions/upload-artifact) and [actions/download-artifact](https://github.com/actions/download-artifact).


Updates `actions/setup-python` from 5.1.0 to 5.1.1
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](82c7e631bb...39cd14951b)

Updates `actions/upload-artifact` from 4.3.3 to 4.3.4
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](65462800fd...0b2256b8c0)

Updates `actions/download-artifact` from 4.1.7 to 4.1.8
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](65a9edc588...fa0a91b85d)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-01 07:36:57 +00:00
dependabot[bot]
ae8b5354e0
Bump the python-requirements group in /requirements with 3 updates
Bumps the python-requirements group in /requirements with 3 updates: [sphinx](https://github.com/sphinx-doc/sphinx), [trio](https://github.com/python-trio/trio) and [pre-commit](https://github.com/pre-commit/pre-commit).


Updates `sphinx` from 7.3.7 to 8.0.2
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/v8.0.2/CHANGES.rst)
- [Commits](https://github.com/sphinx-doc/sphinx/compare/v7.3.7...v8.0.2)

Updates `trio` from 0.25.1 to 0.26.0
- [Release notes](https://github.com/python-trio/trio/releases)
- [Commits](https://github.com/python-trio/trio/compare/v0.25.1...v0.26.0)

Updates `pre-commit` from 3.7.1 to 3.8.0
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v3.7.1...v3.8.0)

---
updated-dependencies:
- dependency-name: sphinx
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: python-requirements
- dependency-name: trio
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: python-requirements
- dependency-name: pre-commit
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: python-requirements
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-01 07:18:20 +00:00
James Addison
f8323cf404
Additional test coverage for async rendering of native type templates (#1807) 2024-07-10 09:14:52 -07:00
David Lord
d7225e65f3
[pre-commit.ci] pre-commit autoupdate (#2001) 2024-07-02 04:17:37 -07:00
pre-commit-ci[bot]
4e04e110e7
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.4.7 → v0.5.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.7...v0.5.0)
2024-07-02 00:15:40 +00:00
David Lord
0087c5fe00
Bump the python-requirements group in /requirements with 2 updates (#1998) 2024-07-01 16:22:58 -07:00
David Lord
e72c1825d4
Bump the github-actions group with 2 updates (#1999) 2024-07-01 12:55:36 -07:00
dependabot[bot]
64b54f2189
Bump the github-actions group with 2 updates
Bumps the github-actions group with 2 updates: [actions/checkout](https://github.com/actions/checkout) and [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish).


Updates `actions/checkout` from 4.1.6 to 4.1.7
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](a5ac7e51b4...692973e3d9)

Updates `pypa/gh-action-pypi-publish` from 1.8.14 to 1.9.0
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](81e9d935c8...ec4db0b4dd)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-01 07:37:23 +00:00
dependabot[bot]
64e6151474
Bump the python-requirements group in /requirements with 2 updates
Bumps the python-requirements group in /requirements with 2 updates: [trio](https://github.com/python-trio/trio) and [tox](https://github.com/tox-dev/tox).


Updates `trio` from 0.22.2 to 0.25.1
- [Release notes](https://github.com/python-trio/trio/releases)
- [Commits](https://github.com/python-trio/trio/compare/v0.22.2...v0.25.1)

Updates `tox` from 4.15.0 to 4.15.1
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/main/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/4.15.0...4.15.1)

---
updated-dependencies:
- dependency-name: trio
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: python-requirements
- dependency-name: tox
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: python-requirements
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-01 07:16:24 +00:00
David Lord
9c6c319899
[pre-commit.ci] pre-commit autoupdate (#1993) 2024-06-03 15:25:15 -07:00
pre-commit-ci[bot]
4b6dac1b6b [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2024-06-03 22:10:44 +00:00
pre-commit-ci[bot]
951868f355
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.4.4 → v0.4.7](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.4...v0.4.7)
2024-06-03 22:10:36 +00:00
David Lord
afb577b313
Bump actions/checkout from 4.1.4 to 4.1.6 in the github-actions group (#1990) 2024-06-01 06:02:39 -07:00
dependabot[bot]
71e374d895
Bump actions/checkout from 4.1.4 to 4.1.6 in the github-actions group
Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout).


Updates `actions/checkout` from 4.1.4 to 4.1.6
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](0ad4b8fada...a5ac7e51b4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-01 07:12:42 +00:00
Timothée Mazzucotelli
1470c17f9f
Convert rST code block to Markdown in README 2024-05-19 09:51:33 -04:00
David Lord
8710cabd4f
Convert rST code block to Markdown in README (#1981) 2024-05-19 09:48:28 -04:00
Timothée Mazzucotelli
90750800d4
Convert rST code block to Markdown in README 2024-05-19 15:32:56 +02:00
David Lord
8a8e2bc4d7
fix test_package_zip_list on 3.13 (#1979) 2024-05-13 12:34:50 -07:00
Thomas Grainger
679af7f816
fix test_package_zip_list on 3.13 2024-05-13 20:04:38 +01:00
David Lord
b002d9c6c3
Merge branch '3.1.x' 2024-05-13 08:47:27 -07:00
David Lord
e82013c399
test with python 3.13 (#1977) 2024-05-13 08:45:44 -07:00
David Lord
004476c22b
test on python 3.13
update dev dependencies
refactor update tox envs
3.7 requires an old version of trio

xfail zip loader template test
2024-05-13 08:40:44 -07:00
Thomas Grainger
1655128cfc
test on trio, fix all missing aclose related warnings (#1960) 2024-05-11 15:01:12 -07:00
David Lord
079e8312c3
use asyncio.run in Template.render (#1952) 2024-05-11 13:45:07 -07:00
Thomas Grainger
5bc613ec45
use asyncio.run 2024-05-11 13:41:46 -07:00
David Lord
2fcabb529f
start version 3.1.5 2024-05-11 13:41:03 -07:00
David Lord
a516a99bab
[pre-commit.ci] pre-commit autoupdate (#1975) 2024-05-06 15:29:13 -07:00
pre-commit-ci[bot]
a89ed5fe0f
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.4.1 → v0.4.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.1...v0.4.3)
2024-05-06 22:05:37 +00:00
David Lord
11550f9df9
Merge branch '3.1.x' 2024-05-05 16:45:28 -07:00
David Lord
6e7b0face6
release version 3.1.4 (#1974) 2024-05-05 16:42:40 -07:00
David Lord
dd4a8b5466
release version 3.1.4 2024-05-05 16:37:30 -07:00
David Lord
0668239dc6
Merge pull request from GHSA-h75v-3vvj-5mfj
disallow invalid characters in keys to xmlattr filter
2024-05-05 16:35:24 -07:00
David Lord
bbd5bcee7b
Merge branch '3.1.x' 2024-05-02 09:18:48 -07:00
David Lord
d655030770
disallow invalid characters in keys to xmlattr filter 2024-05-02 09:14:00 -07:00
David Lord
a7863ba9d3
add ghsa links 2024-05-02 08:42:59 -07:00
David Lord
b5c98e78c2
start version 3.1.4 2024-05-02 08:41:50 -07:00
David Lord
c6dd4bac24
Bump the python-requirements group in /requirements with 5 updates (#1973) 2024-05-01 06:43:12 -07:00
David Lord
6fcf463011
fix mypy findings 2024-05-01 06:41:20 -07:00
David Lord
27ea85b001
Bump the github-actions group with 2 updates (#1972) 2024-05-01 05:54:56 -07:00
dependabot[bot]
2e8bbca767
Bump the python-requirements group in /requirements with 5 updates
Bumps the python-requirements group in /requirements with 5 updates:

| Package | From | To |
| --- | --- | --- |
| [pytest](https://github.com/pytest-dev/pytest) | `8.1.1` | `8.2.0` |
| [pallets-sphinx-themes](https://github.com/pallets/pallets-sphinx-themes) | `2.1.2` | `2.1.3` |
| [mypy](https://github.com/python/mypy) | `1.9.0` | `1.10.0` |
| [pyright](https://github.com/RobertCraigie/pyright-python) | `1.1.359` | `1.1.360` |
| [tox](https://github.com/tox-dev/tox) | `4.14.2` | `4.15.0` |


Updates `pytest` from 8.1.1 to 8.2.0
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/8.1.1...8.2.0)

Updates `pallets-sphinx-themes` from 2.1.2 to 2.1.3
- [Release notes](https://github.com/pallets/pallets-sphinx-themes/releases)
- [Changelog](https://github.com/pallets/pallets-sphinx-themes/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/pallets-sphinx-themes/compare/2.1.2...2.1.3)

Updates `mypy` from 1.9.0 to 1.10.0
- [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md)
- [Commits](https://github.com/python/mypy/compare/1.9.0...v1.10.0)

Updates `pyright` from 1.1.359 to 1.1.360
- [Release notes](https://github.com/RobertCraigie/pyright-python/releases)
- [Commits](https://github.com/RobertCraigie/pyright-python/compare/v1.1.359...v1.1.360)

Updates `tox` from 4.14.2 to 4.15.0
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/main/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/4.14.2...4.15.0)

---
updated-dependencies:
- dependency-name: pytest
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: python-requirements
- dependency-name: pallets-sphinx-themes
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: python-requirements
- dependency-name: mypy
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: python-requirements
- dependency-name: pyright
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: python-requirements
- dependency-name: tox
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: python-requirements
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-01 07:30:56 +00:00
dependabot[bot]
4a7a153a48
Bump the github-actions group with 2 updates
Bumps the github-actions group with 2 updates: [actions/checkout](https://github.com/actions/checkout) and [actions/download-artifact](https://github.com/actions/download-artifact).


Updates `actions/checkout` from 4.1.3 to 4.1.4
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](1d96c772d1...0ad4b8fada)

Updates `actions/download-artifact` from 4.1.6 to 4.1.7
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](9c19ed7fe5...65a9edc588)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-01 07:10:08 +00:00
David Lord
2a17038fca
Revert "upload/download-artifact v4"
This reverts commit c8aca74587.
2024-04-23 16:22:41 -07:00
David Lord
c8aca74587
upload/download-artifact v4 2024-04-23 15:48:42 -07:00
David Lord
9b33637538
Bump the github-actions group across 1 directory with 4 updates (#1970) 2024-04-23 12:35:10 -07:00
dependabot[bot]
2e3e3774a9
Bump the github-actions group across 1 directory with 4 updates
Bumps the github-actions group with 4 updates in the / directory: [actions/checkout](https://github.com/actions/checkout), [actions/upload-artifact](https://github.com/actions/upload-artifact), [slsa-framework/slsa-github-generator](https://github.com/slsa-framework/slsa-github-generator) and [actions/download-artifact](https://github.com/actions/download-artifact).


Updates `actions/checkout` from 4.1.2 to 4.1.3
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](9bb56186c3...1d96c772d1)

Updates `actions/upload-artifact` from 3.1.3 to 4.3.3
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](a8a3f3ad30...65462800fd)

Updates `slsa-framework/slsa-github-generator` from 1.10.0 to 2.0.0
- [Release notes](https://github.com/slsa-framework/slsa-github-generator/releases)
- [Changelog](https://github.com/slsa-framework/slsa-github-generator/blob/main/CHANGELOG.md)
- [Commits](https://github.com/slsa-framework/slsa-github-generator/compare/v1.10.0...v2.0.0)

Updates `actions/download-artifact` from 3.0.2 to 4.1.6
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](9bc31d5ccc...9c19ed7fe5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: slsa-framework/slsa-github-generator
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-23 19:33:07 +00:00
David Lord
6d6a6c2546
unignore upload/download-artifact 2024-04-23 12:32:15 -07:00
David Lord
a2438d20b0
update dev dependencies 2024-04-23 12:23:07 -07:00
David Lord
fcd3d3bbf3
drop support for Python 3.7 2024-04-23 12:22:59 -07:00
David Lord
de6131232a
Merge branch '3.1.x' 2024-04-23 12:07:24 -07:00
David Lord
da3a9f0b80
update project files (#1968) 2024-04-23 10:20:59 -07:00
David Lord
0ee5eb41d1
satisfy formatter, linter, and strict mypy 2024-04-23 09:29:26 -07:00
David Lord
20477c6357
update project files (#5457)
* update pre-commit hooks
* add devcontainer
* show url in publish environment
* update actions versions
* separate typing job
* use dependabot grouped updates
  ignore upload/download-artifact until slsa updates
* use sphinx.ext.extlinks instead of sphinx-issues
* update editorconfig
* update gitignore
* update .readthedocs.yaml
* license is txt, readme is md
* use pyproject.toml and flit_core instead of setuptools
 add typed classifier
 add pyright config
 simplify urls
* tox builds docs in place
* add tox env to update all dev dependencies
* update issue and pr templates
* simplify matrix
2024-04-23 09:28:57 -07:00
David Lord
e491223739
update pyyaml dev dependency 2024-04-22 11:08:14 -07:00
David Lord
3fd91e4d11
Merge branch '3.1.x' 2024-01-10 15:22:02 -08:00
David Lord
36f98854c7
fix pr link 2024-01-10 15:17:32 -08:00
David Lord
a0e864ec0f
release version 3.1.3 (#1926) 2024-01-10 15:12:50 -08:00
David Lord
d9de4bb215
release version 3.1.3 2024-01-10 15:08:43 -08:00
David Lord
50124e1656
skip test pypi 2024-01-10 15:08:33 -08:00
David Lord
9ea7222ef3
use trusted publishing 2024-01-10 15:01:45 -08:00
David Lord
da703f7aae
use trusted publishing 2024-01-10 14:53:37 -08:00
David Lord
bce1746925
use trusted publishing 2024-01-10 14:43:52 -08:00
David Lord
7f8fb54782
use trusted publishing 2024-01-10 14:37:08 -08:00
David Lord
7277d8068b
update pre-commit hooks 2024-01-10 14:33:07 -08:00
David Lord
5c8a105224
Make nested-trans-block exceptions nicer (#1918) 2024-01-10 14:28:47 -08:00
Aarni Koskela
19a55db3b4
Make nested-trans-block exceptions nicer 2024-01-10 14:27:09 -08:00
David Lord
716795349a
Merge pull request from GHSA-h5c8-rqwp-cp95
Raise an exception when spaces are used in HTML attribute keys generated by xmlattr
2024-01-10 14:07:26 -08:00
Calum Hutton
7dd3680e6e
xmlattr filter disallows keys with spaces 2024-01-10 14:01:13 -08:00
David Lord
d594969d72
Bump slsa-framework/slsa-github-generator from 1.7.0 to 1.9.0 (#1885) 2023-09-06 08:59:20 -07:00
David Lord
ec22f25312
Bump pypa/gh-action-pypi-publish from 1.8.8 to 1.8.10 (#1884) 2023-09-06 08:59:11 -07:00
David Lord
21fa43ca01
Bump actions/checkout from 3.5.3 to 3.6.0 (#1883) 2023-09-06 08:59:00 -07:00
dependabot[bot]
938e7ca5bb
Bump slsa-framework/slsa-github-generator from 1.7.0 to 1.9.0
Bumps [slsa-framework/slsa-github-generator](https://github.com/slsa-framework/slsa-github-generator) from 1.7.0 to 1.9.0.
- [Release notes](https://github.com/slsa-framework/slsa-github-generator/releases)
- [Changelog](https://github.com/slsa-framework/slsa-github-generator/blob/main/CHANGELOG.md)
- [Commits](https://github.com/slsa-framework/slsa-github-generator/compare/v1.7.0...v1.9.0)

---
updated-dependencies:
- dependency-name: slsa-framework/slsa-github-generator
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-01 16:03:13 +00:00
dependabot[bot]
f0685845e1
Bump pypa/gh-action-pypi-publish from 1.8.8 to 1.8.10
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.8 to 1.8.10.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](f8c70e705f...b7f401de30)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-01 16:03:08 +00:00
dependabot[bot]
fcafd5087b
Bump actions/checkout from 3.5.3 to 3.6.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 3.6.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](c85c95e3d7...f43a0e5ff2)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-01 16:03:03 +00:00
David Lord
86f28a9df0
Bump pypa/gh-action-pypi-publish from 1.8.7 to 1.8.8 (#1877) 2023-08-01 09:50:36 -07:00
David Lord
f272b6d8b6
Bump actions/setup-python from 4.6.1 to 4.7.0 (#1876) 2023-08-01 09:50:28 -07:00
dependabot[bot]
9db787b566
Bump pypa/gh-action-pypi-publish from 1.8.7 to 1.8.8
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.7 to 1.8.8.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](f5622bde02...f8c70e705f)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-01 16:43:19 +00:00
dependabot[bot]
f575dc7385
Bump actions/setup-python from 4.6.1 to 4.7.0
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.6.1 to 4.7.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](bd6b4b6205...61a6322f88)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-01 16:43:15 +00:00
David Lord
d84a1743e4
[pre-commit.ci] pre-commit autoupdate (#1875) 2023-08-01 09:17:50 -07:00
pre-commit-ci[bot]
4504beba06
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.8.0 → v3.10.1](https://github.com/asottile/pyupgrade/compare/v3.8.0...v3.10.1)
- [github.com/psf/black: 23.3.0 → 23.7.0](https://github.com/psf/black/compare/23.3.0...23.7.0)
- [github.com/PyCQA/flake8: 6.0.0 → 6.1.0](https://github.com/PyCQA/flake8/compare/6.0.0...6.1.0)
2023-08-01 08:46:03 +00:00
David Lord
31b764ea83
[pre-commit.ci] pre-commit autoupdate (#1868) 2023-07-04 06:18:32 -07:00
pre-commit-ci[bot]
ac57ea048d
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.7.0 → v3.8.0](https://github.com/asottile/pyupgrade/compare/v3.7.0...v3.8.0)
2023-07-04 06:36:57 +00:00
David Lord
2a2bfb7f95
Bump actions/checkout from 3.5.2 to 3.5.3 (#1867) 2023-07-01 09:21:29 -07:00
David Lord
ec2649688d
Bump slsa-framework/slsa-github-generator from 1.6.0 to 1.7.0 (#1866) 2023-07-01 09:21:14 -07:00
David Lord
859039244a
Bump dessant/lock-threads from 4.0.0 to 4.0.1 (#1865) 2023-07-01 09:21:06 -07:00
David Lord
890c8a9519
Bump pypa/gh-action-pypi-publish from 1.8.6 to 1.8.7 (#1864) 2023-07-01 09:20:56 -07:00
dependabot[bot]
505effc995
Bump actions/checkout from 3.5.2 to 3.5.3
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.2 to 3.5.3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](8e5e7e5ab8...c85c95e3d7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-01 16:13:15 +00:00
dependabot[bot]
956b1f1ce9
Bump slsa-framework/slsa-github-generator from 1.6.0 to 1.7.0
Bumps [slsa-framework/slsa-github-generator](https://github.com/slsa-framework/slsa-github-generator) from 1.6.0 to 1.7.0.
- [Release notes](https://github.com/slsa-framework/slsa-github-generator/releases)
- [Changelog](https://github.com/slsa-framework/slsa-github-generator/blob/main/CHANGELOG.md)
- [Commits](https://github.com/slsa-framework/slsa-github-generator/compare/v1.6.0...v1.7.0)

---
updated-dependencies:
- dependency-name: slsa-framework/slsa-github-generator
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-01 16:13:11 +00:00
dependabot[bot]
c4b8d066d6
Bump dessant/lock-threads from 4.0.0 to 4.0.1
Bumps [dessant/lock-threads](https://github.com/dessant/lock-threads) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/dessant/lock-threads/releases)
- [Changelog](https://github.com/dessant/lock-threads/blob/main/CHANGELOG.md)
- [Commits](c1b35aecc5...be8aa5be94)

---
updated-dependencies:
- dependency-name: dessant/lock-threads
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-01 16:13:08 +00:00
dependabot[bot]
5258c9d27d
Bump pypa/gh-action-pypi-publish from 1.8.6 to 1.8.7
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.6 to 1.8.7.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](a56da0b891...f5622bde02)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-01 16:13:06 +00:00
David Lord
534c9e13ed
switch to flit build backend (#1863) 2023-06-28 07:44:58 -07:00
David Lord
8310b2bbef
switch to flit build backend 2023-06-28 07:31:12 -07:00
David Lord
fed2d0808f
Merge branch '3.1.x' 2023-06-27 08:01:35 -07:00
David Lord
d80f186832
simplify tox config
envs inherit base testenv
2023-06-27 08:01:19 -07:00
David Lord
c0e4f69ff3
Merge branch '3.1.x' 2023-06-27 07:37:41 -07:00
David Lord
8d0ea74289
update dependencies 2023-06-27 07:36:34 -07:00
David Lord
fd5128f864
[pre-commit.ci] pre-commit autoupdate (#1859) 2023-06-06 09:31:03 -07:00
pre-commit-ci[bot]
02df0dad29
[pre-commit.ci] pre-commit autoupdate
updates:
- https://github.com/asottile/reorder_python_importshttps://github.com/asottile/reorder-python-imports
2023-06-06 04:21:37 +00:00
David Lord
7b48764688
Bump actions/setup-python from 4.6.0 to 4.6.1 (#1856) 2023-06-01 11:49:14 -07:00
David Lord
4b18fd4f1f
Bump pypa/gh-action-pypi-publish from 1.8.5 to 1.8.6 (#1855) 2023-06-01 11:47:50 -07:00
David Lord
3914664578
Bump slsa-framework/slsa-github-generator from 1.5.0 to 1.6.0 (#1857) 2023-06-01 11:46:45 -07:00
David Lord
81a23847cd
Merge branch '3.1.x' 2023-06-01 10:50:38 -07:00
David Lord
ae312b3065
update dependencies 2023-06-01 10:47:07 -07:00
David Lord
051df10c7b
fix check for empty required block (#1858) 2023-06-01 10:42:27 -07:00
David Lord
37f5b058ee
start version 3.1.3 2023-06-01 10:31:10 -07:00
dependabot[bot]
23aab8330c
Bump slsa-framework/slsa-github-generator from 1.5.0 to 1.6.0
Bumps [slsa-framework/slsa-github-generator](https://github.com/slsa-framework/slsa-github-generator) from 1.5.0 to 1.6.0.
- [Release notes](https://github.com/slsa-framework/slsa-github-generator/releases)
- [Changelog](https://github.com/slsa-framework/slsa-github-generator/blob/main/CHANGELOG.md)
- [Commits](https://github.com/slsa-framework/slsa-github-generator/compare/v1.5.0...v1.6.0)

---
updated-dependencies:
- dependency-name: slsa-framework/slsa-github-generator
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-01 16:57:05 +00:00
dependabot[bot]
7e03bef475
Bump actions/setup-python from 4.6.0 to 4.6.1
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.6.0 to 4.6.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](57ded4d7d5...bd6b4b6205)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-01 16:57:00 +00:00
dependabot[bot]
b364f26a11
Bump pypa/gh-action-pypi-publish from 1.8.5 to 1.8.6
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.5 to 1.8.6.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](0bf742be3e...a56da0b891)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-01 16:56:55 +00:00
David Lord
bfceede8ad
remove unused links 2023-06-01 08:09:59 -07:00
David Lord
7e691a0862
update metadata 2023-06-01 08:06:33 -07:00
David Lord
235ecaf576
[pre-commit.ci] pre-commit autoupdate (#1847) 2023-05-02 05:55:07 -07:00
pre-commit-ci[bot]
a24a4b1574
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.3.1 → v3.3.2](https://github.com/asottile/pyupgrade/compare/v3.3.1...v3.3.2)
2023-05-02 04:33:39 +00:00
David Lord
953acd65b2
Bump pypa/gh-action-pypi-publish from 1.8.4 to 1.8.5 (#1843) 2023-05-01 10:21:49 -07:00
David Lord
c5685b6dc4
Bump actions/checkout from 3.5.0 to 3.5.2 (#1844) 2023-05-01 10:19:49 -07:00
dependabot[bot]
7018e3fc76
Bump actions/checkout from 3.5.0 to 3.5.2
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.0 to 3.5.2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](8f4b7f8486...8e5e7e5ab8)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-01 17:17:29 +00:00
David Lord
2cd9ed2ad9
Bump actions/setup-python from 4.5.0 to 4.6.0 (#1845) 2023-05-01 10:16:55 -07:00
dependabot[bot]
1e357f34ff
Bump actions/setup-python from 4.5.0 to 4.6.0
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](d27e3f3d7c...57ded4d7d5)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-01 16:57:11 +00:00
dependabot[bot]
055bbfd1fe
Bump pypa/gh-action-pypi-publish from 1.8.4 to 1.8.5
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.4 to 1.8.5.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](29930c9cf5...0bf742be3e)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-01 16:57:04 +00:00
David Lord
090a5a9e22
fix flake8 bugbear error 2023-04-07 12:19:07 -07:00
David Lord
6fef24ce45
[pre-commit.ci] pre-commit autoupdate (#1831) 2023-04-04 05:14:59 -07:00
pre-commit-ci[bot]
c8c3c846d5
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/psf/black: 23.1.0 → 23.3.0](https://github.com/psf/black/compare/23.1.0...23.3.0)
2023-04-04 06:32:14 +00:00
David Lord
85e5ad85d1
Bump pypa/gh-action-pypi-publish from 1.6.4 to 1.8.4 (#1830) 2023-04-03 06:13:54 -07:00
David Lord
3067df7261
Bump actions/cache from 3.2.6 to 3.3.1 (#1829) 2023-04-03 06:13:47 -07:00
David Lord
23e5cec554
Bump actions/checkout from 3.3.0 to 3.5.0 (#1828) 2023-04-03 06:13:34 -07:00
dependabot[bot]
c48f131143
Bump pypa/gh-action-pypi-publish from 1.6.4 to 1.8.4
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.6.4 to 1.8.4.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](c7f29f7ade...29930c9cf5)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-01 16:57:53 +00:00
dependabot[bot]
4863d6534f
Bump actions/cache from 3.2.6 to 3.3.1
Bumps [actions/cache](https://github.com/actions/cache) from 3.2.6 to 3.3.1.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](69d9d449ac...88522ab9f3)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-01 16:57:47 +00:00
dependabot[bot]
80f4e5586a
Bump actions/checkout from 3.3.0 to 3.5.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.3.0 to 3.5.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](ac59398561...8f4b7f8486)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-01 16:57:43 +00:00
David Lord
be0bcb61f9
[pre-commit.ci] pre-commit autoupdate (#1822) 2023-03-07 06:59:06 -08:00
David Lord
832bdaadfc
address flake8 findings 2023-03-07 06:55:44 -08:00
pre-commit-ci[bot]
f39ffa0d8a
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/peterdemin/pip-compile-multi: v2.6.1 → v2.6.2](https://github.com/peterdemin/pip-compile-multi/compare/v2.6.1...v2.6.2)
2023-03-07 03:52:21 +00:00
David Lord
9dad679695
Bump slsa-framework/slsa-github-generator from 1.4.0 to 1.5.0 (#1816) 2023-03-01 09:04:52 -08:00
David Lord
47957d571c
Bump actions/cache from 3.2.4 to 3.2.6 (#1815) 2023-03-01 09:02:41 -08:00
dependabot[bot]
7b3cb76e71
Bump slsa-framework/slsa-github-generator from 1.4.0 to 1.5.0
Bumps [slsa-framework/slsa-github-generator](https://github.com/slsa-framework/slsa-github-generator) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/slsa-framework/slsa-github-generator/releases)
- [Changelog](https://github.com/slsa-framework/slsa-github-generator/blob/main/CHANGELOG.md)
- [Commits](https://github.com/slsa-framework/slsa-github-generator/compare/v1.4.0...v1.5.0)

---
updated-dependencies:
- dependency-name: slsa-framework/slsa-github-generator
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-01 16:57:30 +00:00
dependabot[bot]
02e058df6c
Bump actions/cache from 3.2.4 to 3.2.6
Bumps [actions/cache](https://github.com/actions/cache) from 3.2.4 to 3.2.6.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](627f0f41f6...69d9d449ac)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-01 16:57:27 +00:00
David Lord
b7cb6ee667
Merge branch '3.1.x' 2023-02-07 07:20:32 -08:00
David Lord
3e07d14a0f
[pre-commit.ci] pre-commit autoupdate (#1800) 2023-02-07 07:12:28 -08:00
pre-commit-ci[bot]
291dfe27d5 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-02-07 04:43:17 +00:00
pre-commit-ci[bot]
42b3a35410
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/psf/black: 22.12.0 → 23.1.0](https://github.com/psf/black/compare/22.12.0...23.1.0)
2023-02-07 04:43:06 +00:00
David Lord
37561cead6
Bump actions/cache from 3.2.3 to 3.2.4 (#1799) 2023-02-01 08:59:04 -08:00
David Lord
56f7c4e083
Bump actions/setup-python from 4.4.0 to 4.5.0 (#1798) 2023-02-01 08:58:53 -08:00
dependabot[bot]
c01f51b345
Bump actions/cache from 3.2.3 to 3.2.4
Bumps [actions/cache](https://github.com/actions/cache) from 3.2.3 to 3.2.4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](58c146cc91...627f0f41f6)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-01 16:01:29 +00:00
dependabot[bot]
1cc0b63e2f
Bump actions/setup-python from 4.4.0 to 4.5.0
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.4.0 to 4.5.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](5ccb29d877...d27e3f3d7c)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-01 16:01:23 +00:00
David Lord
96a83e9014
Merge branch '3.1.x' 2023-01-20 13:35:30 -08:00
David Lord
795ab3db02
build, provenance, publish workflow (#1794) 2023-01-20 13:34:34 -08:00
David Lord
50a5fd4fb2
move and update flake8 config 2023-01-20 11:07:11 -08:00
David Lord
102ba5d688
build, provenance, publish workflow 2023-01-20 09:02:05 -08:00
David Lord
05a5f8120a
switch to pyproject.toml (#1793) 2023-01-19 18:22:50 -08:00
David Lord
8ed8e1d0ed
fix mypy strict findings 2023-01-19 18:17:03 -08:00
David Lord
614b045fab
ignore bugbear opinion 2023-01-19 18:17:03 -08:00
David Lord
a9c8111d24
switch to pyproject.toml 2023-01-19 18:17:03 -08:00
David Lord
048a068697
Merge remote-tracking branch 'origin/3.1.x' 2023-01-19 17:18:57 -08:00
David Lord
89eec1c5ee
set workflow permissions 2023-01-09 14:51:55 -08:00
David Lord
495b889b7c
Merge branch '3.1.x' 2023-01-09 14:51:38 -08:00
David Lord
623df9b3f2
update tested python versions (#1790) 2023-01-09 14:50:52 -08:00
David Lord
782151081d
update tested python versions
test 3.11 final
test 3.12 dev
update for tox 4
2023-01-09 14:47:15 -08:00
David Lord
80e7a83235
Bump actions/cache from 3.0.11 to 3.2.2 (#1787) 2023-01-03 08:23:02 -07:00
David Lord
e46be11e3e
Bump dessant/lock-threads from 3 to 4 (#1786) 2023-01-03 08:22:53 -07:00
dependabot[bot]
45c23ea56d
Bump actions/cache from 3.0.11 to 3.2.2
Bumps [actions/cache](https://github.com/actions/cache) from 3.0.11 to 3.2.2.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3.0.11...v3.2.2)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-01 16:01:00 +00:00
dependabot[bot]
e026c72c19
Bump dessant/lock-threads from 3 to 4
Bumps [dessant/lock-threads](https://github.com/dessant/lock-threads) from 3 to 4.
- [Release notes](https://github.com/dessant/lock-threads/releases)
- [Changelog](https://github.com/dessant/lock-threads/blob/master/CHANGELOG.md)
- [Commits](https://github.com/dessant/lock-threads/compare/v3...v4)

---
updated-dependencies:
- dependency-name: dessant/lock-threads
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-01 16:00:56 +00:00
David Lord
36b601f24b
Merge branch '3.1.x' 2022-12-29 10:39:27 -08:00
David Lord
3fadee01b7
update dependencies 2022-12-29 10:39:00 -08:00
David Lord
5b13cea00a
ignore flake8-bugbear B905 (#1784) 2022-12-29 10:56:15 -07:00
Mehdi ABAAKOUK
522391c5bd
ignore flake8-bugbear B905
requires python>=3.10
2022-12-29 09:54:02 -08:00
Kevin Brown-Silva
e0486050d3
[pre-commit.ci] pre-commit autoupdate (#1772) 2022-12-08 09:25:47 -08:00
pre-commit-ci[bot]
7e691ed15b
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.2.0 → v3.3.0](https://github.com/asottile/pyupgrade/compare/v3.2.0...v3.3.0)
- [github.com/PyCQA/flake8: 5.0.4 → 6.0.0](https://github.com/PyCQA/flake8/compare/5.0.4...6.0.0)
- [github.com/peterdemin/pip-compile-multi: v2.5.0 → v2.6.1](https://github.com/peterdemin/pip-compile-multi/compare/v2.5.0...v2.6.1)
- [github.com/pre-commit/pre-commit-hooks: v4.3.0 → v4.4.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.3.0...v4.4.0)
2022-12-06 00:35:35 +00:00
pre-commit-ci[bot]
6a8246be1e
[pre-commit.ci] pre-commit autoupdate (#1756)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-11-07 20:38:40 -08:00
dependabot[bot]
ae53ea5350
Bump actions/cache from 3.0.9 to 3.0.11 (#1750) 2022-11-01 10:23:17 -07:00
pre-commit-ci[bot]
46298e0c6b
[pre-commit.ci] pre-commit autoupdate (#1748) 2022-11-01 06:53:00 -07:00
David Lord
1746bcdfd5
Update templates.rst (#1742) 2022-10-25 07:09:36 -07:00
neilsquinn
3ccc61b0bd
Update templates.rst
Fix typo
2022-10-25 09:33:24 -04:00
David Lord
5d9ece6d65
Merge branch '3.1.x' 2022-10-13 09:12:06 -07:00
David Lord
bf251517c1
Show how {% filter %} can take filter arguments (#1733) 2022-10-13 09:11:38 -07:00
Simon Willison
b1bb29d292
Show how {% filter %} can take filter arguments
Closes #1732
2022-10-13 09:09:49 -07:00
David Lord
0a10079f33
update dev dependencies 2022-10-13 09:08:56 -07:00
dependabot[bot]
e740cc65d5
Bump actions/cache from 3.0.8 to 3.0.9 (#1729) 2022-10-02 07:03:32 -07:00
pre-commit-ci[bot]
c436c9f18f
[pre-commit.ci] pre-commit autoupdate (#1716) 2022-10-02 07:03:21 -07:00
Anton Topchii
9fde7eb820
Update pylons url in documentation (#1715)
Update pylons homepage url in docs
2022-09-02 06:11:15 -07:00
dependabot[bot]
15e4959a2e
Bump actions/cache from 3.0.5 to 3.0.8 (#1713)
Bumps [actions/cache](https://github.com/actions/cache) from 3.0.5 to 3.0.8.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3.0.5...v3.0.8)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-01 09:09:06 -07:00
Tilman Klaeger
997f7f5243
Replacing os.path.sep with os.sep in loader (#1698) 2022-08-01 17:44:14 -07:00
David Lord
c3fdbac68c
Merge pull request #1700 from pallets/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-08-01 16:23:00 -07:00
pre-commit-ci[bot]
9e1895f0e2
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.34.0 → v2.37.3](https://github.com/asottile/pyupgrade/compare/v2.34.0...v2.37.3)
- [github.com/asottile/reorder_python_imports: v3.3.0 → v3.8.2](https://github.com/asottile/reorder_python_imports/compare/v3.3.0...v3.8.2)
- [github.com/PyCQA/flake8: 4.0.1 → 5.0.2](https://github.com/PyCQA/flake8/compare/4.0.1...5.0.2)
- [github.com/peterdemin/pip-compile-multi: v2.4.5 → v2.4.6](https://github.com/peterdemin/pip-compile-multi/compare/v2.4.5...v2.4.6)
2022-08-01 23:18:35 +00:00
David Lord
7f936deac0
Merge pull request #1699 from pallets/dependabot/github_actions/actions/cache-3.0.5
Bump actions/cache from 3.0.4 to 3.0.5
2022-08-01 09:08:36 -07:00
dependabot[bot]
769921b12b
Bump actions/cache from 3.0.4 to 3.0.5
Bumps [actions/cache](https://github.com/actions/cache) from 3.0.4 to 3.0.5.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3.0.4...v3.0.5)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-01 16:05:50 +00:00
David Lord
f07a7b5229
Merge pull request #1694 from sdidier-dev/docs-patch
Add in docs/switching/#loops little improvement for consistency
2022-07-22 10:12:03 -07:00
Sébastien DIDIER
c4bff4efee Add in docs/switching/#loops little improvement for consistency 2022-07-22 17:47:56 +02:00
David Lord
4bfc33a276
Merge pull request #1685 from sdidier-dev/docs-patch
Fix typo in docs/api/#custom-tests
2022-07-18 07:01:50 -07:00
Sébastien DIDIER
5e636989f0 Fix typo in docs/api/#custom-tests 2022-07-18 15:35:31 +02:00
David Lord
7fb13bf944
Merge pull request #1679 from pallets/dependabot/github_actions/actions/cache-3.0.4
Bump actions/cache from 3.0.3 to 3.0.4
2022-07-04 15:56:42 -07:00
David Lord
32708a5ce8
Merge pull request #1678 from pallets/dependabot/github_actions/actions/setup-python-4
Bump actions/setup-python from 3 to 4
2022-07-04 15:56:36 -07:00
David Lord
94fd2d9241
Merge branch '3.1.x' 2022-07-04 07:40:11 -07:00
David Lord
e9cb0a5fb5
Merge pull request #1682 from pallets/docs-get_template-example
fix get_template example
2022-07-04 07:39:45 -07:00
David Lord
8fec9b4220
fix get_template example 2022-07-04 07:36:59 -07:00
David Lord
fcefbe7472
Merge pull request #1681 from pallets/update-requirements
Update requirements
2022-07-04 07:35:16 -07:00
David Lord
dd22b7a10e
update requirements 2022-07-04 07:26:57 -07:00
David Lord
6089d142c1
move closure out of loop for bugbear B023 2022-07-04 07:26:15 -07:00
David Lord
033bfd12d7
update pre-commit hooks 2022-07-04 07:25:04 -07:00
dependabot[bot]
bd07dfbf18
Bump actions/cache from 3.0.3 to 3.0.4
Bumps [actions/cache](https://github.com/actions/cache) from 3.0.3 to 3.0.4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3.0.3...v3.0.4)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-01 16:06:00 +00:00
dependabot[bot]
b8b2c6b445
Bump actions/setup-python from 3 to 4
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-01 16:05:58 +00:00
David Lord
0d177809e2
Merge pull request #1670 from pallets/dependabot/github_actions/actions/cache-3.0.3
Bump actions/cache from 3.0.2 to 3.0.3
2022-06-01 09:17:20 -07:00
dependabot[bot]
5cede152e8
Bump actions/cache from 3.0.2 to 3.0.3
Bumps [actions/cache](https://github.com/actions/cache) from 3.0.2 to 3.0.3.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3.0.2...v3.0.3)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-01 16:06:19 +00:00
David Lord
c9593aa388
Merge pull request #1662 from pallets/dependabot/github_actions/actions/cache-3.0.2
Bump actions/cache from 3.0.1 to 3.0.2
2022-05-01 10:16:36 -06:00
dependabot[bot]
47493d082c
Bump actions/cache from 3.0.1 to 3.0.2
Bumps [actions/cache](https://github.com/actions/cache) from 3.0.1 to 3.0.2.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3.0.1...v3.0.2)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-01 16:02:59 +00:00
David Lord
1b714c7e82
Merge branch '3.1.x' 2022-04-28 10:22:02 -07:00
David Lord
b08cd4bc64
Merge pull request #1660 from pallets/release-3.1.2
release version 3.1.2
2022-04-28 10:20:01 -07:00
David Lord
1e68ba8617
release version 3.1.2 2022-04-28 10:14:05 -07:00
David Lord
52843b5cbf
Merge branch '3.1.x' 2022-04-28 07:08:26 -07:00
David Lord
8efee35092
pre-commit updates latest release branch 2022-04-28 07:08:16 -07:00
David Lord
a24df26d54
ignore new mypy finding 2022-04-28 07:07:32 -07:00
David Lord
9faee281ea
update requirements 2022-04-28 07:04:19 -07:00
David Lord
b802b5a6ad
Merge pull request #1655 from dvitek/dvitek/issue1654
Fix Race conditions in FileSystemBytecodeCache
2022-04-25 14:14:10 -07:00
David Vitek
746bb95780
Fix race conditions in FileSystemBytecodeCache 2022-04-25 14:09:33 -07:00
David Lord
a0dd7753d0
Merge branch '3.1.x' 2022-04-25 12:41:39 -07:00
David Lord
466a200ea4
update requirements 2022-04-25 12:40:57 -07:00
David Lord
990602f719
Merge pull request #1647 from Tom-Brouwer/202204/add-missing-overlay-options
Add missing environment options to the Environment.overlay method
2022-04-04 06:59:47 -07:00
David Lord
5d3d241471
fix flake8-bugbear finding 2022-04-04 06:56:11 -07:00
Tom Brouwer
21da8f5298
add missing options to overlay from __init__ 2022-04-04 06:40:57 -07:00
David Lord
ea69e41db3
start version 3.1.2 2022-04-04 06:18:39 -07:00
David Lord
c3a61d6ef6
Merge branch '3.1.x' 2022-04-01 12:33:53 -07:00
David Lord
9b521347aa
Merge pull request #1646 from pallets/update-requirements
update requirements
2022-04-01 12:33:42 -07:00
David Lord
8fd4b28a22
update requirements 2022-04-01 12:31:39 -07:00
David Lord
2c8e84db29
Merge pull request #1643 from pallets/dependabot/github_actions/actions/checkout-3
Bump actions/checkout from 2 to 3
2022-04-01 09:08:09 -07:00
David Lord
4f5630f43b
Merge pull request #1644 from pallets/dependabot/github_actions/actions/cache-3.0.1
Bump actions/cache from 2 to 3.0.1
2022-04-01 09:07:10 -07:00
dependabot[bot]
d6b4900742
Bump actions/cache from 2 to 3.0.1
Bumps [actions/cache](https://github.com/actions/cache) from 2 to 3.0.1.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v2...v3.0.1)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-01 16:04:12 +00:00
dependabot[bot]
a7eedafa2a
Bump actions/checkout from 2 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-01 16:04:09 +00:00
David Lord
6f79daafe8
Merge branch '3.1.x' 2022-03-25 15:34:33 -07:00
David Lord
7f66a58a96
Merge pull request #1639 from pallets/release-3.1.1
release version 3.1.1
2022-03-25 15:31:46 -07:00
David Lord
d80ffb47e6
release version 3.1.1 2022-03-25 15:27:45 -07:00
David Lord
f3db5f4b40
Merge pull request #1638 from pallets/windows-altsep
normpath on final template filename
2022-03-25 15:26:46 -07:00
David Lord
1b02fccaf4
normpath on final template filename 2022-03-25 15:23:00 -07:00
David Lord
155e51d90b
start version 3.1.1 2022-03-25 15:05:58 -07:00
David Lord
e542e10002
start version 3.2.0 2022-03-24 07:43:09 -07:00
David Lord
84c0e2cf4e
Merge pull request #1625 from pallets/release-3.1.0
release version 3.1.0
2022-03-24 07:12:26 -07:00
David Lord
7b0c47fe1c
release version 3.1.0 2022-03-24 07:10:11 -07:00
David Lord
ede0f98725
Merge pull request #1621 from pallets/template-safe-path
use `posixpath.join` when loading template names
2022-03-15 14:01:58 -07:00
David Lord
040088a395
use posixpath.join when loading template names 2022-03-15 13:58:22 -07:00
David Lord
a2920752fd
Merge pull request #1620 from janfilips/patch-1
Fix formatting in tricks.rst
2022-03-15 07:01:35 -07:00
Jan Filips
6e4df02773
Fix formatting in tricks.rst 2022-03-15 15:56:40 +02:00
David Lord
3a050b122e
Merge pull request #1617 from pallets/docs-prose
rewrite non-technical documentation
2022-03-12 08:55:57 -08:00
David Lord
4b63cd8f76
rewrite include statement section 2022-03-12 08:48:32 -08:00
David Lord
a98d482186
clean up faq, move technical discussions 2022-03-12 08:26:06 -08:00
David Lord
9de99f8560
clean up engine comparisons 2022-03-12 07:50:49 -08:00
David Lord
ec50af32e9
add flask and django integration 2022-03-12 07:50:29 -08:00
David Lord
350bc53219
Merge pull request #1616 from pallets/docs-sandbox
rewrite sandbox docs, add more security discussion
2022-03-12 06:43:34 -08:00
David Lord
165e972eba
rewrite sandbox docs, add more security discussion 2022-03-12 06:39:31 -08:00
David Lord
186aa82f7e
Merge branch '3.0.x' 2022-03-11 14:38:25 -08:00
David Lord
5962edeb27
Merge branch '2.11.x' into 3.0.x 2022-03-11 14:37:22 -08:00
David Lord
aa3d688a15
Merge branch '2.10.x' into 2.11.x 2022-03-11 14:26:34 -08:00
David Lord
7c3b7ca95c
Merge branch '2.9.x' into 2.10.x 2022-03-11 14:23:40 -08:00
David Lord
70c2d7976b
use current jinja for docs build 2022-03-11 10:07:50 -08:00
David Lord
4bbb1fb5fe
Merge pull request #1368 from mvolfik/refactor-regex
Re-use existing regex for whitespace detection
2022-03-08 07:09:31 -08:00
Matěj Volf
5182b64d1c
Re-use existing regex for whitespace detection
Whitespace regex could also detect newlines, but since we're only
matching the part from last newline, it's safer (and more readable)
to use it here.
2022-03-08 07:06:55 -08:00
David Lord
a12ad40d56
Merge pull request #1465 from wombatonfire/groupby-case-sensitive
Add case_sensitive parameter to groupby() filter
2022-03-08 06:57:02 -08:00
David Lord
e690f7c596
add case_sensitive parameter groupby filter
Co-authored-by: Yuri Sukhov <yuri.sukhov@gmail.com>
2022-03-08 06:55:05 -08:00
David Lord
20eb7f5e33 Merge pull request #1614 from pallets/async-env-filter
add parens around `auto_await` for filters and calls
2022-03-07 09:36:04 -08:00
David Lord
a150ff749a
add parens around auto_await for filters and calls 2022-03-07 09:14:21 -08:00
David Lord
a819eb37bd
Merge pull request #1564 from pallets/feature/pairs
Added items filter
2022-03-07 08:32:45 -08:00
Armin Ronacher
1c036cac2f
add items filter 2022-03-07 08:29:16 -08:00
David Lord
d5b8f668f3
Merge pull request #1613 from dairiki/bug.environment-not-pickleable 2022-03-07 07:56:46 -08:00
Jeff Dairiki
ac3ac6c965
async_variant filters are pickleable 2022-03-07 07:52:04 -08:00
David Lord
09907ef378
Merge pull request #1607 from pallets/dependabot/github_actions/actions/setup-python-3
Bump actions/setup-python from 2 to 3
2022-03-01 08:48:27 -08:00
dependabot[bot]
23f8cd66fc
Bump actions/setup-python from 2 to 3
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 2 to 3.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-01 16:04:23 +00:00
David Lord
bb7f3a5109
Merge branch '3.0.x' 2022-02-18 07:14:18 -08:00
David Lord
681f8de842
Merge pull request #1579 from simonw/patch-1
get_template() uses / separators even on Windows
2022-02-18 07:08:03 -08:00
Simon Willison
e8da6267f8
get_template() uses / separators even on Windows
Refs #1572
2022-02-18 07:00:52 -08:00
David Lord
df59bde6ae
unpin pytest 2022-02-17 17:05:05 -08:00
David Lord
80e6c4bb56
Merge branch '3.0.x' 2022-02-17 17:04:40 -08:00
David Lord
a8ee08141b
Merge pull request #1584 from pallets/update-requirements
update requirements
2022-02-17 17:04:14 -08:00
David Lord
83f8efd680
stop using dependabot for python, too noisy 2022-02-17 16:58:26 -08:00
David Lord
c66adcc574
cache pip with setup-python action 2022-02-17 16:58:13 -08:00
David Lord
070469f19a
use pip-compile-multi for requirements 2022-02-17 16:56:45 -08:00
David Lord
d5edb25f55
update pre-commit hooks 2022-02-17 16:53:43 -08:00
David Lord
c167ddf685
Merge pull request #1574 from adamchainz/docs_html
Update legacy doctype in docs/tricks
2022-01-26 08:23:40 -08:00
Adam Johnson
b81feb86da
Update legacy doctype in docs/tricks 2022-01-26 08:22:05 -08:00
David Lord
077b7918a7
Merge pull request #1571 from pallets/python3.7-identifier-pattern
update identifier pattern for Python 3.7
2022-01-13 15:09:05 -08:00
David Lord
4a33989236
update identifier pattern for Python 3.7 2022-01-13 15:06:18 -08:00
David Lord
b2b41c0c6d
Merge branch '3.0.x' 2022-01-13 14:46:46 -08:00
David Lord
24d3215f06
update tool config 2022-01-13 14:45:55 -08:00
David Lord
27d0687ef7
Merge branch '3.0.x' 2022-01-12 11:47:49 -08:00
David Lord
69f9b087dc
Merge pull request #1570 from pallets/update-requirements
update requirements
2022-01-12 11:47:32 -08:00
David Lord
67f8e67c39
update requirements 2022-01-12 11:40:58 -08:00
David Lord
11065b55a0
Merge remote-tracking branch 'origin/3.0.x' 2021-12-26 16:18:33 -07:00
David Lord
1ba5383727
Merge pull request #1560 from pallets/update-tools
update tools
2021-12-26 16:17:10 -07:00
David Lord
8bc54be214
pin os and python version in rtd build 2021-12-26 16:10:04 -07:00
David Lord
fc59d9a5dd
update option names for v3 2021-12-26 16:07:23 -07:00
David Lord
68617eef38
updates go to maintenance branch 2021-12-26 16:05:29 -07:00
David Lord
4f5c79ce06
Merge pull request #1559 from pallets/i18n-context-block
specify context for translation block
2021-12-26 11:55:30 -07:00
David Lord
b6f50df85b
specify context for translation block 2021-12-26 11:51:54 -07:00
David Lord
896a62135b
Merge branch '3.0.x' 2021-12-26 07:48:45 -07:00
David Lord
54262978d6
Merge pull request #1558 from pallets:update-requirements
update requirements
2021-12-26 07:44:17 -07:00
David Lord
cdc4f1d0d3
fix new mypy findings 2021-12-26 07:39:10 -07:00
David Lord
9dcb94fc2d
update requirements 2021-12-26 07:38:45 -07:00
David Lord
1de766955b
Merge pull request #1557 from bzinberg/patch-1
Typo in docs (trailing backtick)
2021-12-24 19:23:17 -07:00
Ben Zinberg
76cd591975 Typo in docs (trailing backtick)
At least, I _think_ this is a typo? 🙂
2021-12-24 18:22:57 -05:00
David Lord
1c2afd42ca
Merge pull request #1548 from mabdelaal86/patch-1
Fix little typo in docstring
2021-11-28 11:14:18 -08:00
Mohamed Abdelaal
e04df6ed8c
Fix little typo in docstring
Fix a little typo in `do_sort` docstring.
2021-11-28 19:34:23 +01:00
David Lord
7d72eb7fef
Merge pull request #1511 from mkrizek/issue-1510
Support native types in macros
2021-11-10 11:19:29 -08:00
Martin Krizek
2903565262
support native types in macros 2021-11-10 11:17:33 -08:00
David Lord
b285d0c2e6
Merge pull request #1544 from pallets/remove-deprecated-code
remove deprecated code
2021-11-10 11:14:10 -08:00
David Lord
8e980268ff
update docs requirements
new version of pallets-sphinx-themes to address removals
2021-11-10 11:07:04 -08:00
David Lord
04126f9e49
remove deprecated unicode_urlencode 2021-11-10 11:07:04 -08:00
David Lord
6faf093f9d
remove deprecated legacy resolve mode for context subclass 2021-11-10 11:07:04 -08:00
David Lord
88745a2b9e
remove deprecated unicode_join runtime alias 2021-11-10 11:07:04 -08:00
David Lord
824b4d3e5b
remove deprecated Markup and escape aliases 2021-11-10 11:07:04 -08:00
David Lord
c6caa4c5b0
remove deprecated template function decorators 2021-11-10 11:07:04 -08:00
David Lord
ac9dbfcf50
remove deprecated extensions 2021-11-09 12:37:01 -08:00
David Lord
a42b291bf2
Merge branch '3.0.x' 2021-11-09 12:28:39 -08:00
David Lord
2a48dd898d
Merge pull request #1543 from pallets/release-3.0.3
release version 3.0.3
2021-11-09 12:25:09 -08:00
David Lord
ce1a539a69
release version 3.0.3 2021-11-09 12:22:19 -08:00
David Lord
199b6d5ceb
Merge pull request #1542 from pallets/package-loader-file
PackageLoader works with single module file
2021-11-09 12:21:05 -08:00
David Lord
eec0db8642
PackageLoader works with single module file 2021-11-09 12:18:53 -08:00
David Lord
46f3a68183
Merge pull request #1541 from pallets/docs-pow-order
document chained pow order
2021-11-09 10:54:26 -08:00
David Lord
0d1999067b
document chained pow order 2021-11-09 10:52:34 -08:00
David Lord
99daa2a8dc
Merge pull request #1540 from pallets/docs-macro-defaults
rewrite docs about extending template objects
2021-11-09 10:35:56 -08:00
David Lord
a6162daeca
rewrite docs about extending template objects 2021-11-09 10:34:48 -08:00
David Lord
cab5545666
Merge pull request #1539 from pallets/docs-macro-defaults
remove reference to macro.defaults
2021-11-09 10:15:16 -08:00
David Lord
369ff03e09
remove reference to macro.defaults 2021-11-09 10:13:10 -08:00
David Lord
49987a3896
Merge pull request #1538 from pallets/docs-template
rewrite Template class doc
2021-11-09 10:10:05 -08:00
David Lord
3f1e3fccc2
rewrite Template class doc 2021-11-09 10:05:35 -08:00
David Lord
e01e0a21f9
Merge pull request #1509 from kianmeng/fix-typos
Fix typos
2021-11-09 09:17:51 -08:00
David Lord
6aa096a674
Merge pull request #1522 from klette/fix-node-hash
Use `object.__hash__` for `Node.__hash__`
2021-11-09 09:16:49 -08:00
Kristian Klette
9b96b4817a
Use object.__hash__ for Node.__hash__
This fixes a regression in commit 60293416db that
changed the `__hash__` implementation of Node from the default pointer
hash, to a hash based on the node fields.

Since these fields contains list objects, they are not hashable, making
every call to `Node.__hash__` fail.

This breaks some third-party usage such as in `django-compressor`
(See: https://github.com/django-compressor/django-compressor/issues/1060)

This changed reverts the hash method back to using `object.__hash__` as
the hash implementation.
2021-11-09 09:12:22 -08:00
David Lord
c0130ea7dd
Merge pull request #1516 from mohd-akram/async-perf
Reduce async overhead due to auto_await
2021-11-09 08:54:15 -08:00
Mohamed Akram
b756b1924a
Reduce async overhead due to auto_await 2021-11-09 08:52:20 -08:00
David Lord
99b6fc7f37
Merge pull request #1537 from mkrizek/literal_eval-py-310
native: keep same behavior on Python 3.10
2021-11-09 08:46:33 -08:00
Martin Krizek
bb0db82b91
native: keep same behavior on Python 3.10 2021-11-09 08:41:02 -08:00
David Lord
a4e2532489
Merge pull request #1536 from pallets/traceback-codetype
simplify CodeType rewriting
2021-11-09 08:27:21 -08:00
David Lord
99435a4e69
simplify CodeType rewriting 2021-11-09 07:10:53 -08:00
David Lord
b2bc7be67f
Merge pull request #1534 from pallets/drop-python-3.6
drop Python 3.6
2021-11-08 08:23:31 -08:00
David Lord
5308c9588d
drop Python 3.6 2021-11-08 08:07:29 -08:00
David Lord
5e2385ca0c
Merge branch '3.0.x' 2021-11-05 07:22:41 -07:00
David Lord
a83aded810
Merge pull request #1527 from hroncok/py3.11-tracebacks
Tests: Adapt expected traceback regexes for Python 3.11.0a1
2021-11-05 07:22:28 -07:00
Miro Hrončok
757756696c
Tests: Adapt expected traceback regexes for Python 3.11.0a1
Fixes https://github.com/pallets/jinja/issues/1526

Before:

      File ".../broken.html", line 2, in <module>
        {{ fail() }}
      File ".../test_debug.py", line 32, in <lambda>
        tmpl.render(fail=lambda: 1 / 0)
    ZeroDivisionError: division by zero

After:

      File ".../broken.html", line 2, in <module>
        {{ fail() }}
        ^^^^^^^^^^^^
      File ".../test_debug.py", line 32, in <lambda>
        tmpl.render(fail=lambda: 1 / 0)
                                 ~~^~~
    ZeroDivisionError: division by zero
2021-11-05 07:19:04 -07:00
David Lord
acd4e343ee
Merge pull request #1531 from pallets/test-3.11
test Python 3.11
2021-11-05 07:18:41 -07:00
David Lord
aa27de364a
test Python 3.11 2021-11-05 07:15:25 -07:00
David Lord
423cbfa89a
update py==1.11.0 to work on Python 3.11 2021-11-05 07:13:12 -07:00
David Lord
b16028cf8c
Merge branch '3.0.x' 2021-11-05 06:46:22 -07:00
David Lord
7e98f23538
Merge pull request #1530 from pallets/test-3.10
test Python 3.10
2021-11-05 06:45:06 -07:00
David Lord
34eb205e83
test Python 3.10 2021-11-05 06:34:17 -07:00
David Lord
f72597b8cc
Merge pull request #1525 from hroncok/patch-1
Tests: Make "Traceback did not match" an actual f-string
2021-11-02 09:25:12 -07:00
Miro Hrončok
e32c985af3
Tests: Make "Traceback did not match" an actual f-string
Otherwise the failure looks like this:

    >       assert (
                m is not None
            ), "Traceback did not match:\n\n{''.join(tb)}\nexpected:\n{expected_tb}"
    E       AssertionError: Traceback did not match:
    E         
    E         {''.join(tb)}
    E         expected:
    E         {expected_tb}
    E       assert None is not None
2021-11-02 16:47:28 +01:00
David Lord
15f02c471c
Merge branch '3.0.x' 2021-11-01 12:48:16 -07:00
David Lord
d5a436c279
Merge pull request #1524 from pallets/update-requirements
update requirements
2021-11-01 12:47:56 -07:00
David Lord
23619d33da
update requirements 2021-11-01 12:44:28 -07:00
Kian-Meng, Ang
8cc3a64fa6 Fix typos 2021-10-12 22:36:44 +08:00
David Lord
f20a9c9ccb
Merge branch '3.0.x' 2021-10-04 17:54:36 -07:00
David Lord
b7d12b6b15
Merge pull request #1506 from pallets/release-3.0.2
release version 3.0.2
2021-10-04 17:53:10 -07:00
David Lord
76c9cf832a
release version 3.0.2 2021-10-04 17:48:23 -07:00
David Lord
28ef40cb0c
Merge pull request #1505 from pallets/package-loader-path
omit curdir from PackageLoader root path
2021-10-04 17:45:34 -07:00
David Lord
8931077058
omit curdir from PackageLoader root path
fixes compatibility with zip imports

Co-authored-by: kuepe-sl <peter_kueffner@web.de>
2021-10-04 17:39:39 -07:00
David Lord
355ef53451
Merge pull request #1495 from daniel-stoneuk/patch-async-globals 2021-10-04 13:51:05 -07:00
Daniel Stone
baff54fe1d
imported macros can access template globals in async mode 2021-10-04 13:49:13 -07:00
David Lord
e20a52ed50
Merge branch '3.0.x' 2021-10-04 13:28:06 -07:00
David Lord
fb9cac66e9
Merge pull request #1504 from pallets/update-requirements
update requirements
2021-10-04 13:25:34 -07:00
David Lord
ad1ebe30f2
apply pyupgrade 2021-10-04 13:22:49 -07:00
David Lord
c287f61adc
update pre-commit hooks 2021-10-04 13:22:34 -07:00
David Lord
28c7d492e1
update requirements 2021-10-04 13:22:22 -07:00
David Lord
362cdcfd9d
Merge pull request #1503 from pallets/except-chain
use exception chaining
2021-10-04 13:19:54 -07:00
David Lord
a99f8c150b
use exception chaining
fixes flake8-bugbear B904
2021-10-04 13:16:13 -07:00
David Lord
03146f50c5
Merge pull request #1501 from pallets/ignore-internal-warning
ignore internal asyncio warning
2021-10-04 12:47:32 -07:00
David Lord
5fdec22242
ignore internal asyncio warning
https://bugs.python.org/issue45097
2021-10-04 12:43:17 -07:00
David Lord
647677d37f
Merge pull request #1492 from pallets/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-09-08 08:19:10 -07:00
pre-commit-ci[bot]
9d9ca1a415
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.23.1 → v2.25.0](https://github.com/asottile/pyupgrade/compare/v2.23.1...v2.25.0)
- [github.com/psf/black: 21.7b0 → 21.8b0](https://github.com/psf/black/compare/21.7b0...21.8b0)
2021-09-06 19:09:13 +00:00
David Lord
060145192a
Merge pull request #1490 from pallets/dependabot/pip/tox-3.24.3
Bump tox from 3.24.1 to 3.24.3
2021-09-01 08:30:13 -07:00
dependabot[bot]
03e81c9116
Bump tox from 3.24.1 to 3.24.3
Bumps [tox](https://github.com/tox-dev/tox) from 3.24.1 to 3.24.3.
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/3.24.1...3.24.3)

---
updated-dependencies:
- dependency-name: tox
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-01 15:19:50 +00:00
David Lord
2b42ae5d25
Merge pull request #1489 from pallets/dependabot/pip/pre-commit-2.14.1
Bump pre-commit from 2.13.0 to 2.14.1
2021-09-01 08:17:04 -07:00
David Lord
0946f5edaa
Merge pull request #1491 from pallets/dependabot/pip/pytest-6.2.5
Bump pytest from 6.2.4 to 6.2.5
2021-09-01 08:16:54 -07:00
dependabot[bot]
5e5fe8badf
Bump pytest from 6.2.4 to 6.2.5
Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.2.4 to 6.2.5.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/6.2.4...6.2.5)

---
updated-dependencies:
- dependency-name: pytest
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-01 08:03:33 +00:00
dependabot[bot]
a80643a7dc
Bump pre-commit from 2.13.0 to 2.14.1
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.13.0 to 2.14.1.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.13.0...v2.14.1)

---
updated-dependencies:
- dependency-name: pre-commit
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-01 08:02:33 +00:00
nabbisen
8cef6b89c5 replace http with https in docs 2021-08-28 09:12:38 -04:00
David Lord
35c69e9ec3
Merge remote-tracking branch 'origin/3.0.x' 2021-08-10 06:34:22 -07:00
David Lord
024fa10f10
Merge pull request #1482 from esadek/pip_link
update pip link
2021-08-10 06:18:48 -07:00
Emil Sadek
62cbc9b6e8
update pip link 2021-08-10 06:08:06 -07:00
David Lord
531145d28b
Merge pull request #1455 from ewjoachim/undefined-contains-1204
Only StrictUndefined.__contains__ raises error
2021-08-09 11:10:01 -07:00
Joachim Jablon
d5f49f5cc1
Fixes #1448: Revert Undefined.__contains__ to 2.x behaviour 2021-08-09 11:07:35 -07:00
David Lord
1891320941
Merge pull request #1454 from atetubou/deterministic_test
make compile_templates deterministic
2021-08-09 11:00:30 -07:00
Takuto Ikuta
4c703ec44d
make compile_templates deterministic
Python3 doesn't keep insertion order for set(), so this sorts some
places for deterministic output for compiled template.
2021-08-09 10:58:24 -07:00
David Lord
02071b3e59
Merge pull request #1449 from amy-lei/loop-scoping
fix loop scoping bug
2021-08-09 10:19:58 -07:00
David Lord
3aeefed85a
Merge pull request #1479 from pallets/dependabot/pip/tox-3.24.1
Bump tox from 3.23.1 to 3.24.1
2021-08-03 06:59:26 -07:00
David Lord
44f3d2142c
Merge pull request #1480 from pallets/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-08-03 06:12:27 -07:00
pre-commit-ci[bot]
1b4c25991b [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2021-08-02 18:54:03 +00:00
pre-commit-ci[bot]
6d3e679894
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.20.0 → v2.23.1](https://github.com/asottile/pyupgrade/compare/v2.20.0...v2.23.1)
- [github.com/asottile/reorder_python_imports: v2.5.0 → v2.6.0](https://github.com/asottile/reorder_python_imports/compare/v2.5.0...v2.6.0)
- [github.com/psf/black: 21.6b0 → 21.7b0](https://github.com/psf/black/compare/21.6b0...21.7b0)
2021-08-02 18:50:31 +00:00
dependabot[bot]
30449e16f1
Bump tox from 3.23.1 to 3.24.1
Bumps [tox](https://github.com/tox-dev/tox) from 3.23.1 to 3.24.1.
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/3.23.1...3.24.1)

---
updated-dependencies:
- dependency-name: tox
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-01 08:08:17 +00:00
David Lord
c6334b6cec
Merge pull request #1472 from pallets/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-07-06 06:34:37 -07:00
pre-commit-ci[bot]
9c32e56696
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.15.0 → v2.20.0](https://github.com/asottile/pyupgrade/compare/v2.15.0...v2.20.0)
- [github.com/psf/black: 21.5b1 → 21.6b0](https://github.com/psf/black/compare/21.5b1...21.6b0)
- [github.com/pre-commit/pre-commit-hooks: v3.4.0 → v4.0.1](https://github.com/pre-commit/pre-commit-hooks/compare/v3.4.0...v4.0.1)
2021-07-05 22:13:33 +00:00
David Lord
683942164b
Merge pull request #1469 from pallets/dependabot/pip/pip-tools-6.2.0
Bump pip-tools from 6.1.0 to 6.2.0
2021-07-01 05:57:43 -07:00
dependabot[bot]
6e0a5cce6f
Bump pip-tools from 6.1.0 to 6.2.0
Bumps [pip-tools](https://github.com/jazzband/pip-tools) from 6.1.0 to 6.2.0.
- [Release notes](https://github.com/jazzband/pip-tools/releases)
- [Changelog](https://github.com/jazzband/pip-tools/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jazzband/pip-tools/compare/6.1.0...6.2.0)

---
updated-dependencies:
- dependency-name: pip-tools
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-01 12:53:16 +00:00
David Lord
a059ba9478
Merge pull request #1470 from pallets/dependabot/pip/mypy-0.910
Bump mypy from 0.812 to 0.910
2021-07-01 05:52:03 -07:00
dependabot[bot]
a90eda882c
Bump mypy from 0.812 to 0.910
Bumps [mypy](https://github.com/python/mypy) from 0.812 to 0.910.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v0.812...v0.910)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-01 08:04:09 +00:00
David Lord
8c031bf203
Merge pull request #1457 from pallets/dependabot/pip/pre-commit-2.13.0
Bump pre-commit from 2.12.1 to 2.13.0
2021-06-01 06:33:53 -07:00
dependabot[bot]
af0125eccf
Bump pre-commit from 2.12.1 to 2.13.0
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.12.1 to 2.13.0.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.12.1...v2.13.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-01 08:05:07 +00:00
David Lord
d4e5112550
Merge pull request #1451 from greyli/improve-contributing-guide
Improve the contributing guide
2021-05-25 06:44:22 -07:00
Grey Li
1d3d466c63 Improve the contributing guide 2021-05-25 08:51:55 +08:00
Amy
f3bc9c6a91
clear assignments in loops at end of iteration 2021-05-21 11:24:04 -07:00
David Lord
d1ff9cef88
Merge branch '3.0.x' 2021-05-20 20:53:16 -07:00
David Lord
1037184acd
Merge pull request #1447 from pallets/update-theme
Update theme
2021-05-20 20:52:48 -07:00
David Lord
5f09dc4cc0
update pallets and sphinx requirements 2021-05-20 20:49:38 -07:00
David Lord
570f94cc10
update pallets-sphinx-themes 2021-05-20 20:48:16 -07:00
David Lord
cdbda09e44
Merge branch '3.0.x' 2021-05-18 13:40:36 -07:00
David Lord
738644d816
start version 3.0.2.dev0 2021-05-18 13:39:52 -07:00
David Lord
3b3e16fc18
Merge pull request #1445 from pallets/release-3.0.1
release version 3.0.1
2021-05-18 13:37:58 -07:00
David Lord
4d23bfb317
release version 3.0.1 2021-05-18 13:35:09 -07:00
David Lord
77674b9dfb
Merge pull request #1444 from pallets/event-loop
use asyncio.run
2021-05-18 13:31:11 -07:00
David Lord
7d0b7accff
use asyncio.run 2021-05-18 13:22:46 -07:00
David Lord
94a6423a77
Merge pull request #1442 from dannysepler/use-pathlib-in-places
Use pathlib in some test places
2021-05-18 10:32:26 -07:00
Danny Sepler
06c646df2d
Use pathlib in some test places 2021-05-18 10:30:11 -07:00
David Lord
9f5db9a6d9
Merge pull request #1440 from pallets/deprecated-markup
fix deprecated `Markup` subclass
2021-05-17 06:48:44 -07:00
David Lord
ab7840328f
Merge pull request #1439 from pallets/deprecated-markup
fix deprecated `Markup` subclass
2021-05-17 06:45:26 -07:00
David Lord
f562a4fdea
fix deprecated Markup subclass 2021-05-17 06:41:42 -07:00
David Lord
55848d36c0
Merge branch '3.0.x' 2021-05-13 18:01:18 -07:00
David Lord
fb564a84af
Merge pull request #1436 from pallets/deprecated-extensions
fix context for deprecated extensions
2021-05-13 17:54:32 -07:00
David Lord
b4d31e7b8d
show context for deprecated extensions 2021-05-13 17:48:19 -07:00
David Lord
426c56032c
Merge pull request #1435 from pallets/update-typing
Update typing
2021-05-13 17:35:29 -07:00
David Lord
a2e83d07a3
Merge pull request #1434 from pallets/update-typing
Update typing
2021-05-13 17:30:40 -07:00
David Lord
9f34d2ac87
fix typing that wasn't available in Python 3.6.0 2021-05-13 17:25:08 -07:00
David Lord
db5fb7971f
mark top-level names as exported 2021-05-13 17:19:23 -07:00
David Lord
f1c51b39f9
Merge remote-tracking branch 'origin/3.0.x' 2021-05-11 16:25:55 -07:00
David Lord
21fa00b6fc
Merge pull request #1420 from pallets/default-branch
rename default branch in files
2021-05-11 16:25:39 -07:00
David Lord
9b86bbce63
rename default branch in files 2021-05-11 16:24:15 -07:00
David Lord
e7dce0b3b1
Merge pull request #1419 from ThiefMaster/fix-sphinx-build
Install sphinx 4.1-dev from git
2021-05-11 16:15:13 -07:00
Adrian Moennich
3a9c8f25ba Remove type annotation breaking sphinx builds 2021-05-12 01:06:44 +02:00
Adrian Moennich
b5323b2414 Install sphinx 4.1-dev from git
Otherwise docs builds are broken due to sphinx-doc/sphinx#9216
2021-05-12 01:06:40 +02:00
David Lord
1c4066a4fa
Merge remote-tracking branch 'origin/3.0.x' 2021-05-11 14:23:25 -07:00
David Lord
d5357f9304
Merge pull request #1418 from pallets/update-markupsafe
update markupsafe minimum version
2021-05-11 14:23:04 -07:00
David Lord
e2f673e604
update markupsafe minimum version 2021-05-11 14:21:06 -07:00
David Lord
c2d8b9551f
start version 3.1.0.dev0 2021-05-11 14:10:43 -07:00
David Lord
058c06f24d
start version 3.0.1.dev0 2021-05-11 14:10:02 -07:00
David Lord
417f822196
Merge pull request #1417 from pallets/release-3.0.0
Release 3.0.0
2021-05-11 14:04:48 -07:00
David Lord
b15fd1c94c
release version 3.0.0 2021-05-11 14:02:01 -07:00
David Lord
eed1546e19
update requirements 2021-05-11 14:01:39 -07:00
David Lord
9627e73aa7
Merge pull request #1416 from pallets/pre-commit-ci-schedule
update pre-commit monthly
2021-05-11 07:09:27 -07:00
David Lord
6630044b57
update pre-commit monthly 2021-05-11 07:05:21 -07:00
David Lord
e1bf3bc362
Merge pull request #1415 from pallets/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-05-10 13:41:59 -07:00
pre-commit-ci[bot]
0798a6616e
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.14.0 → v2.15.0](https://github.com/asottile/pyupgrade/compare/v2.14.0...v2.15.0)
- [github.com/psf/black: 21.4b2 → 21.5b1](https://github.com/psf/black/compare/21.4b2...21.5b1)
- [github.com/PyCQA/flake8: 3.9.1 → 3.9.2](https://github.com/PyCQA/flake8/compare/3.9.1...3.9.2)
2021-05-10 20:26:14 +00:00
David Lord
53fea337d1
Merge pull request #1414 from pallets/typing-marker
fix py.typed in manifest
2021-05-10 06:58:42 -07:00
David Lord
ba1f27e11b
fix py.typed in manifest 2021-05-10 06:53:52 -07:00
David Lord
1a3342b27e
Merge pull request #1412 from pallets/typing
add type annotations
2021-05-08 13:38:35 -07:00
David Lord
be15556dba
add type annotations 2021-05-08 13:03:15 -07:00
David Lord
f418f719c1
Merge pull request #1411 from pallets/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-05-03 11:13:49 -07:00
pre-commit-ci[bot]
47a404d4c6
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.13.0 → v2.14.0](https://github.com/asottile/pyupgrade/compare/v2.13.0...v2.14.0)
- [github.com/psf/black: 21.4b0 → 21.4b2](https://github.com/psf/black/compare/21.4b0...21.4b2)
2021-05-03 17:22:40 +00:00
dependabot[bot]
1b1050fb5a
Merge pull request #1410 from pallets/dependabot/pip/babel-2.9.1 2021-04-28 20:57:26 +00:00
dependabot[bot]
c21795b2d0
Merge pull request #1409 from pallets/dependabot/pip/pre-commit-2.12.1 2021-04-28 20:56:09 +00:00
dependabot[bot]
0ce9686680
Bump babel from 2.9.0 to 2.9.1
Bumps [babel](https://github.com/python-babel/babel) from 2.9.0 to 2.9.1.
- [Release notes](https://github.com/python-babel/babel/releases)
- [Changelog](https://github.com/python-babel/babel/blob/master/CHANGES)
- [Commits](https://github.com/python-babel/babel/compare/v2.9.0...v2.9.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-28 20:55:15 +00:00
dependabot[bot]
8c4cd04dc2
Bump pre-commit from 2.12.0 to 2.12.1
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.12.0 to 2.12.1.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.12.0...v2.12.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-28 20:54:26 +00:00
David Lord
508a7f39f1
Merge pull request #1408 from pallets/dependabot/add-v2-config-file
Upgrade to GitHub-native Dependabot
2021-04-28 13:53:11 -07:00
dependabot-preview[bot]
782d223e9d
Upgrade to GitHub-native Dependabot 2021-04-28 16:46:45 +00:00
David Lord
db239d22e4
Merge pull request #1407 from pallets/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-04-27 06:28:15 -07:00
pre-commit-ci[bot]
7fa2ff34b7
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.12.0 → v2.13.0](https://github.com/asottile/pyupgrade/compare/v2.12.0...v2.13.0)
- [github.com/asottile/reorder_python_imports: v2.4.0 → v2.5.0](https://github.com/asottile/reorder_python_imports/compare/v2.4.0...v2.5.0)
- [github.com/psf/black: 20.8b1 → 21.4b0](https://github.com/psf/black/compare/20.8b1...21.4b0)
2021-04-26 17:22:03 +00:00
David Lord
ac8d8d69fe
Merge pull request #1406 from pallets/release-3.0.0rc2
release version 3.0.0rc2
2021-04-25 08:11:17 -07:00
David Lord
8d1d9e16bc
release version 3.0.0rc2 2021-04-25 08:08:40 -07:00
David Lord
38839c7006
Merge pull request #1401 from pallets/deprecated-markup
fix deprecated `Markup` subclass
2021-04-17 18:39:40 -07:00
David Lord
e802be7520
fix Markup subclass
str subclass must override __new__ instead of __init__
2021-04-17 18:17:47 -07:00
David Lord
d77a91b1cb
Merge pull request #1399 from pallets/release-3.0.0rc1
Release 3.0.0rc1
2021-04-16 08:24:21 -07:00
David Lord
8179a3c2da
release version 3.0.0rc1 2021-04-16 08:21:34 -07:00
David Lord
8169a9db2a
update minimum install requirements 2021-04-16 08:21:12 -07:00
David Lord
9784db5388
update deprecated pre-commit hook 2021-04-16 08:18:09 -07:00
David Lord
bac57a70fe
update requirements 2021-04-16 08:17:55 -07:00
David Lord
954e8f0145
update pallets-sphinx-themes 2021-04-16 08:17:18 -07:00
David Lord
b98182fc37
mention jinja in deprecation message 2021-04-15 15:32:57 -07:00
David Lord
f04bde8334
Merge pull request #1398 from pallets/docs-filter-anchor
unique links for filters, tests, globals
2021-04-13 10:41:17 -07:00
David Lord
f61cc84dba
unique links for filters, tests, globals 2021-04-13 10:36:11 -07:00
David Lord
414a8c4365
Merge pull request #1394 from pallets/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-04-12 10:24:41 -07:00
pre-commit-ci[bot]
d43430791f
[pre-commit.ci] pre-commit autoupdate 2021-04-12 17:12:51 +00:00
David Lord
06230b0022
Merge pull request #1393 from pallets/deprecate-legacy-resolve
deprecate legacy resolve mode
2021-04-11 23:58:46 -07:00
David Lord
912e59d51f
deprecate legacy resolve mode 2021-04-11 23:53:59 -07:00
David Lord
9d4689b04d
Merge pull request #1392 from pallets/inline-async
async support doesn't require patching
2021-04-11 18:55:36 -07:00
David Lord
1932ce3dc4
async support doesn't require patching 2021-04-10 16:12:25 -07:00
David Lord
a9b06f4bd2
Merge pull request #1391 from pallets/markupsafe-imports
Markup and escape should be imported from markupsafe
2021-04-10 10:24:58 -07:00
David Lord
aafe94d97a
Markup and escape should be imported from markupsafe 2021-04-10 10:22:24 -07:00
David Lord
39846a887b
Merge pull request #1389 from pallets/unify-decorators
unify/rename context function decorators
2021-04-10 10:19:30 -07:00
David Lord
788d8bc172
unify/rename filter and function decorators
Use pass_context instead of contextfilter and contextfunction, etc.
2021-04-10 10:14:42 -07:00
David Lord
c8db6c6313
extract common code for import/from nodes 2021-04-10 08:58:43 -07:00
David Lord
94b381da23
Merge pull request #1152 from angelafrentz/refactor_ternary_statement_compiler 2021-04-09 15:33:14 -07:00
angelafrentz
8c97ae57d1
refactor compiler environment.is_async checks 2021-04-09 15:27:58 -07:00
dependabot-preview[bot]
841fb295eb
Merge pull request #1387 from pallets/dependabot/pip/urllib3-1.26.4 2021-04-06 18:03:18 +00:00
dependabot-preview[bot]
20d4766b27
[Security] Bump urllib3 from 1.26.3 to 1.26.4
Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.26.3 to 1.26.4. **This update includes a security fix.**
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](https://github.com/urllib3/urllib3/compare/1.26.3...1.26.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-06 18:01:52 +00:00
David Lord
c752dc8183
Merge pull request #1360 from lisongmin/add-default-value-to-groupby
Ability to set default value in groupby filter
2021-04-05 14:44:37 -07:00
lisongmin
34fbec9a72
add default parameter to groupby 2021-04-05 14:42:34 -07:00
David Lord
4a941cab0d
Merge pull request #1367 from mvolfik/docs-fix
line statements have no default
2021-04-05 14:27:12 -07:00
Matěj Volf
671cbd73fe
Fix incorrect docs - line statements have no default 2021-04-05 14:26:14 -07:00
David Lord
eaf0cca37b
Merge pull request #1364 from Dreamsorcerer/patch-2
Fix map documentation
2021-04-05 14:23:33 -07:00
Sam Bull
da48bb0d20
Fix map documentation 2021-04-05 14:19:33 -07:00
David Lord
e45eabccf0
Merge pull request #1236 from sixtyfathoms/fix/issue-1184
Update wording on dictionary default ordering
2021-04-05 14:18:56 -07:00
jeff
0fa20045b0
update wording on dictionary default ordering 2021-04-05 14:17:01 -07:00
David Lord
851f7aff57
Merge pull request #1226 from geographika/patch-1
Add symbol names for tilde and pipe
2021-04-05 14:08:20 -07:00
Seth G
1fa864a561
add symbol names for tilde and pipe operators 2021-04-05 14:06:35 -07:00
David Lord
4abb2a0739
Merge pull request #1366 from mvolfik/fix-unicode-newlines
Fix unicode newlines
2021-04-05 11:50:38 -07:00
Matěj Volf
9dae67bcc8
Split lines in lexer only by \r\n, \r and \n
Python str.splitlines() splits by more characters[1], which, however,
causes problems when keeping these special characters in processed
templates is desirable, i.e. these bug reports: #769, #952, #1313.

The keep_trailing_newlines logic is reworked because splitlines()
removes them already (so they had to be added), while re.split doesn't
so they have to be removed.

[1] https://docs.python.org/3/library/stdtypes.html#str.splitlines
2021-04-05 11:46:36 -07:00
David Lord
59de6fbde9
Merge pull request #1363 from remidebette/add-native-async-support
Add async support to NativeEnvironment
2021-04-05 11:38:54 -07:00
remidebette
3642ae7fef
NativeEnvironment supports async mode 2021-04-05 11:36:54 -07:00
David Lord
06c7c6fee1
Merge pull request #1294 from Jafnee/chainableundefined-aiter-bug
Add __aiter__ to Undefined
2021-04-05 10:53:57 -07:00
Jafnee
3242428c52
add Undefined.__aiter__ 2021-04-05 10:51:29 -07:00
David Lord
139c3eee81
Merge pull request #1204 from dparker2/undefined-contains
Raise UndefinedError from Undefined.__contains__
2021-04-05 10:46:24 -07:00
David Parker
609bcb0831
Undefined.__contains__ raises UndefinedError 2021-04-05 10:44:31 -07:00
David Lord
fd001b216a
Merge pull request #1171 from amykyta3/feature/base-integer-literals
Add support for hex, octal, and binary integer literals
2021-04-05 10:40:02 -07:00
Alex Mykyta
2e0a3da2bc
parse hex, octal, and binary integer literals 2021-04-05 10:35:57 -07:00
David Lord
1eb871fdc3
Merge pull request #1385 from pallets/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-04-05 10:24:35 -07:00
pre-commit-ci[bot]
ea1ccb670c
[pre-commit.ci] pre-commit autoupdate 2021-04-05 17:10:51 +00:00
David Lord
1b874db337
Merge pull request #1167 from LarsKollstedt/allow_indent_with_generic_char
indent filter can indent with arbitrary characters
2021-04-05 09:53:29 -07:00
Lars Kollstedt
8016b5f139
filters.py: do_indent: ident filter can indent with arbitrary characters
Allow indention with generic characters, e.g. Tabs.

Implemenented the behavior requested in
https://github.com/pallets/jinja/pull/1167#issuecomment-612644701

The width param can be string or int, if it is string it's the raw
indention e.g. "\t". If it's int it's the number of spaces. In other
cases an FilterArgumentError is raised, to avoid confusion.
2021-04-05 09:50:45 -07:00
David Lord
7bea9193f4
Merge pull request #1384 from pallets/typing-filters-tests
add type annotations to filters and tests
2021-04-05 09:33:52 -07:00
David Lord
f0a9f319b7
add type annotations to filters and tests 2021-04-05 09:25:26 -07:00
Adrian
43d4228930
Merge pull request #1126 from imomaliev/pgettext-support
add pgettext to InternationalizationExtension
2021-04-05 13:57:00 +02:00
Sardorbek Imomaliev
3fba898098
add pgettext and npgettext 2021-04-05 04:45:05 -07:00
David Lord
beabf304b0
Merge pull request #1383 from pallets/test-decorators
add 'is filter' and 'is test' tests
2021-04-04 17:39:15 -07:00
David Lord
6c733602ac
add 'is filter' and 'is test' tests
This required allowing tests to be decorated with '@environmentfilter'.
Tests are essentially the same as filters now, the node, compiler, and
environment have been refactored to extract common behavior.
2021-04-04 17:20:23 -07:00
David Lord
af5d80e999
Merge pull request #1248 from MLH-Fellowship/test-for-filter
allow optional use of a filter based on its existence
2021-04-04 10:20:49 -07:00
Amy
ebf0e2dfda allow optional use of filter based on existence 2021-04-04 13:09:31 -04:00
David Lord
1c863d0447
Merge pull request #1374 from pallets/docs-globals
Template globals use ChainMap, more docs about globals
2021-03-31 17:21:21 -07:00
David Lord
38e45fead3
more detailed docs about globals 2021-03-31 16:09:51 -07:00
David Lord
40a312e80f
Merge pull request #1244 from MLH-Fellowship/cache-bugs
Fix bug with cached templates not registering new globals
2021-03-30 07:49:51 -07:00
Amy
49d5f9788c fix bug with cached templates not using new globals 2021-03-30 01:43:51 -04:00
Amy Lei
f71f5ebab2
Merge pull request #1242 from MLH-Fellowship/context-bug
fix bugs with contextfunction and nested loop variables
2021-03-26 18:44:19 -04:00
Amy
f524bcce0c track local loop/block vars for contextfunctions 2021-03-26 16:45:25 -04:00
Amy
fed1b24d5f allow scoped blocks to access loop vars 2021-03-26 16:44:36 -04:00
David Lord
94ccd028ef
Merge pull request #1371 from pallets/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-03-22 10:50:29 -07:00
pre-commit-ci[bot]
57b3386226
[pre-commit.ci] pre-commit autoupdate 2021-03-22 17:05:35 +00:00
David Lord
1351ccef2a
Merge pull request #1369 from pallets/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-03-15 11:37:08 -07:00
pre-commit-ci[bot]
45278afcd1
[pre-commit.ci] pre-commit autoupdate 2021-03-15 17:01:18 +00:00
David Lord
8ab9db26f3
Merge pull request #1356 from BALaka-18/map-filter-default
Map filter can use False as default
2021-02-24 17:18:38 -08:00
BALaka-18
73a94e00d4
map filter can use False as default 2021-02-24 17:16:01 -08:00
David Lord
ab9cd8c664
Merge pull request #1361 from pallets/consistency
various cleanup for consistency between projects
2021-02-24 10:38:10 -08:00
David Lord
e381730a73
move version to setup.cfg 2021-02-24 09:50:00 -08:00
David Lord
6f182be55b
cache mypy in ci 2021-02-24 09:49:31 -08:00
David Lord
d2cef39355
consistent typing config 2021-02-24 09:49:12 -08:00
David Lord
9b3c64d5c4
docs rename changelog to changes, add license 2021-02-24 09:46:54 -08:00
David Lord
3f6a7e8ea9
update project links 2021-02-24 09:46:20 -08:00
David Lord
75e6ecf05c
use rtd to build docs for prs
skip code tests when only docs change
2021-02-16 08:41:40 -08:00
David Lord
e6577e9a36
simplify dev install command 2021-02-08 11:57:06 -08:00
David Lord
1edc5dccd5
Merge pull request #1351 from pallets/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-02-08 09:13:06 -08:00
pre-commit-ci[bot]
5f4bb16af9
[pre-commit.ci] pre-commit autoupdate 2021-02-08 16:52:04 +00:00
David Lord
8aa4f4fbeb
Merge pull request #1350 from pallets/update-test-requirements
update requirements, test Python 3.9
2021-02-06 20:40:52 -08:00
David Lord
33ff819a38
update requirements, test Python 3.9 2021-02-06 20:35:29 -08:00
sixtyfathoms
c580dd08b5
update building docs instructions in contributing guide (#1235) 2021-02-04 11:02:48 -05:00
David Lord
71d81c6fca
update contributing guide 2021-02-02 09:52:15 -08:00
David Lord
f009a004a2
Merge pull request #1348 from pallets/json-docs
update tojson docs
2021-02-01 22:48:29 -08:00
David Lord
f2fdf18610
update tojson docs 2021-02-01 22:35:43 -08:00
pre-commit-ci[bot]
fcf014f80c
[pre-commit.ci] pre-commit autoupdate (#1347) 2021-02-01 09:01:49 -08:00
dependabot-preview[bot]
9e6cc047b5
Merge pull request #1346 from pallets/dependabot/pip/pytest-6.2.2 2021-02-01 10:07:22 +00:00
dependabot-preview[bot]
69898fd4f6
Merge pull request #1345 from pallets/dependabot/pip/pre-commit-2.10.0 2021-02-01 10:07:15 +00:00
dependabot-preview[bot]
b003afdbd5
Bump pytest from 6.2.1 to 6.2.2
Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.2.1 to 6.2.2.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/6.2.1...6.2.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-01 09:55:12 +00:00
dependabot-preview[bot]
88023b7043
Bump pre-commit from 2.9.3 to 2.10.0
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.9.3 to 2.10.0.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.9.3...v2.10.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-01 09:55:02 +00:00
dependabot-preview[bot]
c74ae61c16
Merge pull request #1344 from pallets/dependabot/pip/tox-3.21.3 2021-02-01 09:53:33 +00:00
dependabot-preview[bot]
362f0136aa
Bump tox from 3.20.1 to 3.21.3
Bumps [tox](https://github.com/tox-dev/tox) from 3.20.1 to 3.21.3.
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/3.20.1...3.21.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-01 09:49:33 +00:00
David Lord
076d380361
Merge branch '2.11.x' 2021-01-31 08:48:44 -08:00
David Lord
cf215390d4
release version 2.11.3 2021-01-31 08:44:37 -08:00
David Lord
15ef8f09b6
Merge pull request #1343 from pallets/urlize-speedup
backport urlize speedup
2021-01-31 08:15:28 -08:00
David Lord
ef658dc3b6
speed up urlize matching 2021-01-31 08:02:04 -08:00
David Lord
1cad38c44b
Merge pull request #1310 from pallets/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-01-30 23:09:37 -08:00
David Lord
a30f92d246
fix new formatting issues 2021-01-30 23:07:30 -08:00
pre-commit-ci[bot]
e993a9d48c
[pre-commit.ci] pre-commit autoupdate 2021-01-30 22:56:23 -08:00
David Lord
f1b1caf003
Merge pull request #1195 from bebleo/add_mailto_link_support
Improve and extend urlize
2021-01-30 22:55:14 -08:00
David Lord
1aa979c545
refactor urlize function
don't try other url types if one already matched
no-op function if trim is not enabled
avoid backtracking when matching trailing punctuation
match head and tail punctuation separately
don't scan for unbalanced parentheses more than necessary
ensure email domain starts and ends with a word character
2021-01-30 22:20:17 -08:00
sixtyfathoms
2f41690b3b
update docs on adding extensions (#1237) 2021-01-30 19:20:26 -05:00
David Lord
be83e7e06c
update urlize docs, clean up code
move regexes near implementation
commented verbose regex for http pattern
renamed extra_uri_schemes to extra_schemes
2021-01-30 13:38:56 -08:00
Roy Smith
30c23f5795
Improve diction (amount -> number) (#1341) 2021-01-30 07:53:38 -08:00
Bebleo
d504e1d1e2
Improve and extend urlize 2021-01-30 06:25:03 -08:00
David Lord
c3b34a06f3
update docs about required blocks (#1340) 2021-01-30 05:47:23 -08:00
Amy Lei
b5a00c854e
Merge pull request #1243 from MLH-Fellowship/deprecate-extension
deprecate 'autoescape'  and 'with' extensions for removal in 3.1
2021-01-29 22:17:45 -05:00
FawziyahAlebiosu
1843d6d411 deprecate 'with' and 'autoescape' extensions 2021-01-29 16:56:47 -05:00
Amy Lei
35e8f0a09d
Merge pull request #1233 from MLH-Fellowship/required-blocks
add required attribute to blocks
2021-01-29 10:36:54 -05:00
Amy
8da77f9753 add required attribute to blocks
required blocks must be overridden at some point, although not
necessarily by the direct child template
2021-01-29 10:28:39 -05:00
David Lord
bc22a8b0d3
Merge pull request #1339 from mkrizek/issue-1335
native_concat: pass only strings to literal_eval
2021-01-28 06:19:59 -08:00
Martin Krizek
bd8bad37d1 native_concat: pass only strings to literal_eval
If there is only single node and it is not a string, there is no point
in passing it into ``literal_eval``, just return it immediately.

One of the examples where passing a non-string node into
``literal_eval`` would actually cause problems is when the node is
``Undefined``. On Python 3.10 this would cause ``UndefinedError``
instead of just ``Undefined`` being returned.

Fixes #1335
2021-01-28 12:13:30 +01:00
Adam Johnson
8d69d20c1d
Fix "If" example in documentation (#1337)
Fix "If" example in documentation
2021-01-26 05:38:00 -08:00
Thomas Moschny
5f79ba633d
add 'linetable' to the preserved CodeType attributes (#1334)
add 'linetable' to the preserved CodeType attributes

co_linetable replaces co_lnotab as part of PEP 626 in Python 3.10.
2021-01-19 12:01:18 -08:00
dependabot-preview[bot]
e39c87c4d4
Merge pull request #1329 from pallets/dependabot/pip/pytest-6.2.1 2021-01-01 08:39:58 +00:00
dependabot-preview[bot]
fefaa0dce3
Bump pytest from 6.1.2 to 6.2.1
Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.1.2 to 6.2.1.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/6.1.2...6.2.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-01 08:35:39 +00:00
dependabot-preview[bot]
fa47946731
Merge pull request #1330 from pallets/dependabot/pip/pre-commit-2.9.3 2021-01-01 08:34:04 +00:00
dependabot-preview[bot]
58254a5064
Bump pre-commit from 2.9.2 to 2.9.3
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.9.2 to 2.9.3.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.9.2...v2.9.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-01 08:31:30 +00:00
dependabot-preview[bot]
31037d1cb2
Merge pull request #1328 from pallets/dependabot/pip/pip-tools-5.5.0 2021-01-01 08:29:58 +00:00
dependabot-preview[bot]
5b9614410a
Bump pip-tools from 5.4.0 to 5.5.0
Bumps [pip-tools](https://github.com/jazzband/pip-tools) from 5.4.0 to 5.5.0.
- [Release notes](https://github.com/jazzband/pip-tools/releases)
- [Changelog](https://github.com/jazzband/pip-tools/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jazzband/pip-tools/compare/5.4.0...5.5.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-01 08:28:10 +00:00
Jonathan Berger
81911fdb30
Update templates.rst to fix small typo (#1327) 2020-12-23 04:53:08 -08:00
dependabot-preview[bot]
1c24015486
Merge pull request #1322 from pallets/dependabot/pip/pre-commit-2.9.2 2020-12-01 09:07:37 +00:00
dependabot-preview[bot]
9a481fce73
Merge pull request #1321 from pallets/dependabot/pip/babel-2.9.0 2020-12-01 08:59:12 +00:00
dependabot-preview[bot]
0d501b3aa2
Bump pre-commit from 2.8.2 to 2.9.2
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.8.2 to 2.9.2.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.8.2...v2.9.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-01 08:59:04 +00:00
dependabot-preview[bot]
9ce239d884
Merge pull request #1320 from pallets/dependabot/pip/pip-tools-5.4.0 2020-12-01 08:57:25 +00:00
dependabot-preview[bot]
a3b98aa7b0
Bump babel from 2.8.0 to 2.9.0
Bumps [babel](https://github.com/python-babel/babel) from 2.8.0 to 2.9.0.
- [Release notes](https://github.com/python-babel/babel/releases)
- [Changelog](https://github.com/python-babel/babel/blob/master/CHANGES)
- [Commits](https://github.com/python-babel/babel/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-01 08:53:45 +00:00
dependabot-preview[bot]
de3125f0d7
Bump pip-tools from 5.3.1 to 5.4.0
Bumps [pip-tools](https://github.com/jazzband/pip-tools) from 5.3.1 to 5.4.0.
- [Release notes](https://github.com/jazzband/pip-tools/releases)
- [Changelog](https://github.com/jazzband/pip-tools/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jazzband/pip-tools/compare/5.3.1...5.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-01 08:53:04 +00:00
David Lord
9242a027c9
reduce lock schedule to daily 2020-11-13 16:27:25 -08:00
David Lord
028a62d852
add lock threads workflow 2020-11-13 11:39:21 -08:00
dependabot-preview[bot]
2bd091ec8f
Merge pull request #1306 from pallets/dependabot/pip/pre-commit-2.8.2 2020-11-01 08:38:15 +00:00
dependabot-preview[bot]
c4655291ac
Bump pre-commit from 2.7.1 to 2.8.2
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.7.1 to 2.8.2.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.7.1...v2.8.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-01 08:36:40 +00:00
dependabot-preview[bot]
d3253b0ef8
Merge pull request #1307 from pallets/dependabot/pip/pytest-6.1.2 2020-11-01 08:35:12 +00:00
dependabot-preview[bot]
c9e44bfe5e
Bump pytest from 6.1.0 to 6.1.2
Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.1.0 to 6.1.2.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/6.1.0...6.1.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-01 08:32:41 +00:00
dependabot-preview[bot]
d2a66cdd74
Merge pull request #1305 from pallets/dependabot/pip/tox-3.20.1 2020-11-01 08:31:03 +00:00
dependabot-preview[bot]
4ea65c882d
Bump tox from 3.20.0 to 3.20.1
Bumps [tox](https://github.com/tox-dev/tox) from 3.20.0 to 3.20.1.
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/3.20.0...3.20.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-01 08:27:16 +00:00
David Lord
1eca37ba6d
Merge pull request #1303 from gibson042/gh-1279-custom-async-filters
Fix custom async filters
2020-10-31 19:09:22 -07:00
Richard Gibson
e1d0131a7f
detect custom async filters in as_const 2020-10-31 19:07:26 -07:00
David Lord
27c65757b2
Merge pull request #1247 from MLH-Fellowship/type-hints
Setup mypy
2020-10-21 06:05:09 -07:00
dependabot-preview[bot]
64ade528f3
Merge pull request #1296 from pallets/dependabot/pip/pytest-6.1.0 2020-10-01 08:26:36 +00:00
dependabot-preview[bot]
e589a42db4
Bump pytest from 6.0.2 to 6.1.0
Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.0.2 to 6.1.0.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/6.0.2...6.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-01 08:24:17 +00:00
dependabot-preview[bot]
26e97c5dd7
Merge pull request #1292 from pallets/dependabot/pip/pytest-6.0.2 2020-09-14 08:21:28 +00:00
dependabot-preview[bot]
24a37a3c9e
Bump pytest from 6.0.1 to 6.0.2
Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.0.1 to 6.0.2.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/6.0.1...6.0.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-14 08:18:41 +00:00
dependabot-preview[bot]
5046bebb2b
Merge pull request #1291 from pallets/dependabot/pip/tox-3.20.0 2020-09-07 08:21:18 +00:00
dependabot-preview[bot]
55391acabc
Bump tox from 3.19.0 to 3.20.0
Bumps [tox](https://github.com/tox-dev/tox) from 3.19.0 to 3.20.0.
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/3.19.0...3.20.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-07 08:18:43 +00:00
Peter Bittner
ab81fd9c27
Add GitHub templates from Werkzeug (#1282) 2020-08-29 15:19:09 -07:00
dependabot-preview[bot]
61edc8e9ce
Merge pull request #1281 from pallets/dependabot/pip/pre-commit-2.7.1 2020-08-24 08:19:47 +00:00
dependabot-preview[bot]
6b9400f588
Bump pre-commit from 2.6.0 to 2.7.1
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.6.0 to 2.7.1.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.6.0...v2.7.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-24 08:17:46 +00:00
dependabot-preview[bot]
d9756e1acc
Merge pull request #1277 from pallets/dependabot/pip/tox-3.19.0 2020-08-07 07:56:20 +00:00
dependabot-preview[bot]
2b9035e2df
Bump tox from 3.18.1 to 3.19.0
Bumps [tox](https://github.com/tox-dev/tox) from 3.18.1 to 3.19.0.
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/3.18.1...3.19.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-07 07:54:31 +00:00
dependabot-preview[bot]
7a2215f28b
Merge pull request #1274 from pallets/dependabot/pip/pip-tools-5.3.1 2020-08-03 08:58:05 +00:00
dependabot-preview[bot]
59e9778ce1
Bump pip-tools from 5.3.0 to 5.3.1
Bumps [pip-tools](https://github.com/jazzband/pip-tools) from 5.3.0 to 5.3.1.
- [Release notes](https://github.com/jazzband/pip-tools/releases)
- [Changelog](https://github.com/jazzband/pip-tools/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jazzband/pip-tools/compare/5.3.0...5.3.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-03 08:56:02 +00:00
dependabot-preview[bot]
e49942a54c
Merge pull request #1271 from pallets/dependabot/pip/pytest-6.0.1 2020-07-31 08:34:56 +00:00
dependabot-preview[bot]
8a9305cc27
Bump pytest from 6.0.0 to 6.0.1
Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.0.0 to 6.0.1.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/6.0.0...6.0.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-31 08:32:16 +00:00
dependabot-preview[bot]
ece6349447
Merge pull request #1268 from pallets/dependabot/pip/tox-3.18.1 2020-07-29 08:33:10 +00:00
dependabot-preview[bot]
24b42a1397
Bump tox from 3.18.0 to 3.18.1
Bumps [tox](https://github.com/tox-dev/tox) from 3.18.0 to 3.18.1.
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/3.18.0...3.18.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-29 08:30:46 +00:00
dependabot-preview[bot]
ba4d9cb72f
Merge pull request #1267 from pallets/dependabot/pip/pytest-6.0.0 2020-07-29 08:26:12 +00:00
dependabot-preview[bot]
b25a4415e8
Bump pytest from 5.4.3 to 6.0.0
Bumps [pytest](https://github.com/pytest-dev/pytest) from 5.4.3 to 6.0.0.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/5.4.3...6.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-29 08:23:17 +00:00
Teymour Aldridge
50ae5b6ac7 Setup mypy
* Add missing type hints (these are intended as an initial set of type hints, to be added upon and improved later)
* Setup MyPy to run as a Github Action
2020-07-28 22:32:34 +01:00
dependabot-preview[bot]
0399bcaf53
Merge pull request #1266 from pallets/dependabot/pip/pip-tools-5.3.0 2020-07-27 08:42:27 +00:00
dependabot-preview[bot]
9594e7b4e6
Bump pip-tools from 5.2.1 to 5.3.0
Bumps [pip-tools](https://github.com/jazzband/pip-tools) from 5.2.1 to 5.3.0.
- [Release notes](https://github.com/jazzband/pip-tools/releases)
- [Changelog](https://github.com/jazzband/pip-tools/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jazzband/pip-tools/compare/5.2.1...5.3.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-27 08:39:11 +00:00
dependabot-preview[bot]
42793a022b
Merge pull request #1263 from pallets/dependabot/pip/tox-3.18.0 2020-07-24 08:05:42 +00:00
dependabot-preview[bot]
22adaa021f
Bump tox from 3.17.1 to 3.18.0
Bumps [tox](https://github.com/tox-dev/tox) from 3.17.1 to 3.18.0.
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/3.17.1...3.18.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-24 08:03:23 +00:00
dependabot-preview[bot]
96ff62bcb7
Merge pull request #1260 from pallets/dependabot/pip/tox-3.17.1 2020-07-16 08:25:22 +00:00
dependabot-preview[bot]
bf26836f05
Bump tox from 3.17.0 to 3.17.1
Bumps [tox](https://github.com/tox-dev/tox) from 3.17.0 to 3.17.1.
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/3.17.0...3.17.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-16 08:23:28 +00:00
dependabot-preview[bot]
49dc70f930
Merge pull request #1259 from pallets/dependabot/pip/tox-3.17.0 2020-07-15 08:14:33 +00:00
dependabot-preview[bot]
9fe69487a5
Bump tox from 3.16.1 to 3.17.0
Bumps [tox](https://github.com/tox-dev/tox) from 3.16.1 to 3.17.0.
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/3.17.0/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/3.16.1...3.17.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-15 08:11:18 +00:00
dependabot-preview[bot]
b5f454559f
Merge pull request #1254 from pallets/dependabot/pip/pre-commit-2.6.0 2020-07-02 08:24:30 +00:00
dependabot-preview[bot]
1886b4dae3
Bump pre-commit from 2.5.1 to 2.6.0
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.5.1 to 2.6.0.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.5.1...v2.6.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-02 08:21:16 +00:00
David Lord
cd41cacc5f
move metadata to setup.cfg 2020-07-01 09:33:03 -07:00
dependabot-preview[bot]
e8d032b027
Merge pull request #1251 from pallets/dependabot/pip/tox-3.16.1 2020-06-30 08:16:21 +00:00
dependabot-preview[bot]
32c1ed793b
Bump tox from 3.16.0 to 3.16.1
Bumps [tox](https://github.com/tox-dev/tox) from 3.16.0 to 3.16.1.
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/3.16.0...3.16.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-30 08:14:02 +00:00
dependabot-preview[bot]
f70dc1d67d
Merge pull request #1250 from pallets/dependabot/pip/tox-3.16.0 2020-06-29 08:42:05 +00:00
dependabot-preview[bot]
3909d71aed
Bump tox from 3.15.2 to 3.16.0
Bumps [tox](https://github.com/tox-dev/tox) from 3.15.2 to 3.16.0.
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/3.15.2...3.16.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-29 08:40:10 +00:00
David Lord
03c719f3ec
Merge pull request #1240 from MLH-Fellowship/ignore-trim-blocks
Allow +%} to ignore trim_blocks
2020-06-22 10:34:40 -07:00
Amy
6b0122768f
ignore trim_blocks using '+%}' 2020-06-22 10:21:47 -07:00
David Lord
9b718ed3d2
Merge pull request #1241 from MLH-Fellowship/macros_with_globals
Fix bug with imported macros and template globals
2020-06-22 10:12:46 -07:00
Amy
cc792d8c91
imported templates can see the current globals
_get_default_module takes an optional context to indicate that the
template is imported. If there are differences between the environment
and rendered template globals, a new module is used for the imported
template.
2020-06-22 09:56:10 -07:00
Amy
cd88dec8ea add more tests for import context behavior 2020-06-19 11:53:29 -04:00
David Lord
5eea6e49e0
Merge pull request #1238 from MLH-Fellowship/1197-sandbox
Remove sandbox Python < 3.5 compat
2020-06-15 11:08:47 -07:00
Amy
6de60977ac remove sandbox._MagicFormatMapping
add test for escape formatter
2020-06-15 13:49:40 -04:00
David Lord
8816c9335b
add contributing guide 2020-06-11 19:43:53 -07:00
dependabot-preview[bot]
1e3f669bb2
Merge pull request #1232 from pallets/dependabot/pip/pre-commit-2.5.1 2020-06-10 08:51:10 +00:00
dependabot-preview[bot]
9750618eca
Bump pre-commit from 2.5.0 to 2.5.1
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.5.0 to 2.5.1.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.5.0...v2.5.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-10 08:48:22 +00:00
dependabot-preview[bot]
a8dd46d446
Merge pull request #1231 from pallets/dependabot/pip/pip-tools-5.2.1 2020-06-10 08:46:42 +00:00
dependabot-preview[bot]
5380a3c551
Bump pip-tools from 5.2.0 to 5.2.1
Bumps [pip-tools](https://github.com/jazzband/pip-tools) from 5.2.0 to 5.2.1.
- [Release notes](https://github.com/jazzband/pip-tools/releases)
- [Changelog](https://github.com/jazzband/pip-tools/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jazzband/pip-tools/compare/5.2.0...5.2.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-10 08:44:49 +00:00
dependabot-preview[bot]
350fa6c389
Merge pull request #1230 from pallets/dependabot/pip/pre-commit-2.5.0 2020-06-09 08:24:18 +00:00
dependabot-preview[bot]
7b9db4f62e
Bump pre-commit from 2.4.0 to 2.5.0
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.4.0 to 2.5.0.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.4.0...v2.5.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-09 08:21:54 +00:00
dependabot-preview[bot]
acf6ce76e3
Merge pull request #1229 from pallets/dependabot/pip/tox-3.15.2 2020-06-08 14:14:06 +00:00
dependabot-preview[bot]
feeffb7d88
Bump tox from 3.15.1 to 3.15.2
Bumps [tox](https://github.com/tox-dev/tox) from 3.15.1 to 3.15.2.
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/3.15.1...3.15.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-08 08:44:54 +00:00
David Lord
6c99856518
Merge pull request #1228 from pallets/dependabot/pip/pytest-5.4.3
Bump pytest from 5.4.2 to 5.4.3
2020-06-03 07:45:28 -07:00
dependabot-preview[bot]
6d32d36b84
Bump pytest from 5.4.2 to 5.4.3
Bumps [pytest](https://github.com/pytest-dev/pytest) from 5.4.2 to 5.4.3.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/5.4.2...5.4.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-03 08:52:31 +00:00
dependabot-preview[bot]
fb068e5c3a
Bump pip-tools from 5.1.2 to 5.2.0 (#1227)
Bumps [pip-tools](https://github.com/jazzband/pip-tools) from 5.1.2 to 5.2.0.
- [Release notes](https://github.com/jazzband/pip-tools/releases)
- [Changelog](https://github.com/jazzband/pip-tools/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jazzband/pip-tools/compare/5.1.2...5.2.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-05-28 08:53:45 -07:00
David Lord
6b347e7b29
add EditorConfig 2020-05-23 13:23:49 -07:00
David Lord
a51a0cff34
Merge pull request #1225 from pallets/github-actions
use GitHub Actions for CI
2020-05-23 13:05:13 -07:00
David Lord
4ccfe85cc1
use GitHub Actions for CI 2020-05-23 13:03:15 -07:00
David Lord
ca8b0b0287
Merge pull request #1224 from pallets/loader-docs
update package and filesystem loader docs
2020-05-23 12:30:50 -07:00
David Lord
2408a55bbe
update package and filesystem loader docs 2020-05-23 12:21:44 -07:00
David Lord
2ad167726c
Merge pull request #1222 from pallets/dependabot/pip/tox-3.15.1
Bump tox from 3.15.0 to 3.15.1
2020-05-23 11:13:46 -07:00
dependabot-preview[bot]
8e0afc2647
Bump tox from 3.15.0 to 3.15.1
Bumps [tox](https://github.com/tox-dev/tox) from 3.15.0 to 3.15.1.
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/3.15.0...3.15.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-23 18:12:14 +00:00
David Lord
3e41c01caa
Merge pull request #1221 from pallets/remove-docs-dev
remove docs requirements from dev requirments
2020-05-23 10:58:45 -07:00
David Lord
8388b141be
remove docs requirements from dev requirments
otherwise Sphinx will cause Jinja to be pinned
2020-05-23 10:45:23 -07:00
David Lord
ef69935b37
try another dependabot ignore pattern 2020-05-18 16:21:04 -07:00
David Lord
b9637225bb
try another dependabot ignore pattern 2020-05-18 15:59:09 -07:00
David Lord
9046b77cff
fix dependabot config syntax 2020-05-18 15:56:23 -07:00
David Lord
b038ec3d91
Merge pull request #1216 from pallets/dependabot-config
try to make dependabot ignore editable line
2020-05-18 15:53:07 -07:00
David Lord
097ce4cde5
try to make dependabot ignore editable line 2020-05-18 15:49:08 -07:00
David Lord
fc92af3c7b
Merge pull request #1214 from pallets/requirements
use pip-compile to pin dev requirements
2020-05-18 15:31:58 -07:00
David Lord
24cc61df5f
use pip-compile to pin dev requirements 2020-05-18 15:25:33 -07:00
David Lord
4e7befbf64
Merge pull request #1213 from pallets/rtd-config
add readthedocs config
2020-05-18 14:58:52 -07:00
David Lord
6a48679ece
add readthedocs config 2020-05-18 14:56:41 -07:00
David Lord
eeca0fecc3
Merge pull request #1207 from mhansen/patch-1
api.rst: bugfix in docs, import PackageLoader
2020-05-16 07:40:45 -07:00
David Lord
2dd769111c
Merge pull request #1209 from mhansen/patch-3
do_dictsort: update example ready to copy/paste
2020-05-16 07:24:53 -07:00
Mark Hansen
48929401db
do_dictsort: update example ready to copy/paste
When iterating over a dict you usually want to pull out the keys and values.
2020-05-16 17:07:59 +10:00
Mark Hansen
7db7d336ba
api.rst: bugfix in docs, import PackageLoader
It's used two lines below.
2020-05-16 16:04:48 +10:00
David Lord
6478c22f29
Merge pull request #1196 from pallets/remove-vim
remove vim syntax file
2020-04-19 09:01:07 -07:00
David Lord
29cd9273f5
remove vim syntax file
remove unmaintained information from integration doc
2020-04-19 08:55:59 -07:00
David Lord
da812816ff
Merge branch '2.11.x' 2020-04-13 09:26:39 -07:00
David Lord
9ec465baef
fix changelog header 2020-04-13 09:20:59 -07:00
David Lord
737a4cd41d
release version 2.11.2 2020-04-13 09:12:19 -07:00
David Lord
179df6b54e
Merge pull request #1190 from pallets/native-eval
native only evals at end of render
2020-04-13 08:56:37 -07:00
David Lord
f75cb42e4f
native only evals at end of render
Co-authored-by: Martin Krizek <mkrizek@redhat.com>
2020-04-13 08:51:38 -07:00
David Lord
f1756a3b44
Merge pull request #1183 from exponea/1138-fix-unintended-lstrip-behavior-change
Fix unintended lstrip_blocks behavior
2020-04-13 07:09:31 -07:00
Peter Dolak
7163513a35 Add tests for lstrip whitespace behavior fix
Also did peformance tests for the previous fix and saw no measurable
impact.
2020-04-13 14:14:03 +02:00
Peter Dolak
dbbd082bce Fix unintended lstrip_blocks behavior. Fixes #1138
Introduced in #858. Tests will follow, also results of performance
testing.
2020-04-13 14:13:16 +02:00
Ken Crowell
91eb39b153
Don't use setlocal in syntax file (#1164)
I'm not 100% sure that one should not use `setlocal` in a syntax file,
but this breaks other filetypes that may include this syntax file, like
the vim-markdown plugin.  The `comments` and `commentstring` get set for
that markdown buffer with the jinja settings.

See
https://github.com/dhruvasagar/vim-table-mode/issues/162#issuecomment-595317626
for an example of side effects.
2020-04-12 09:46:08 -07:00
Xinbin Huang
35aa1948c0
Update oudated CutomLoader code example (#1185)
py3 for CustomLoader example
2020-04-08 13:15:30 -07:00
David Lord
169b676a00
Merge branch '2.11.x' 2020-04-08 08:53:28 -07:00
David Lord
4a70cd480f
Merge tag '2.11.1' into 2.11.x 2020-04-08 08:52:03 -07:00
David Lord
bff4893d5f
Merge pull request #1169 from asottile/pep_451
Use importlib machinery to fix PEP 451 import hooks
2020-03-30 13:03:04 -07:00
David Lord
c0675781a5
add changelog and cleanup for pep 451 support 2020-03-30 12:55:40 -07:00
Anthony Sottile
a524e77eec
Use importlib machinery to fix PEP 451 import hooks 2020-03-30 11:41:34 -07:00
David Lord
0a370316c6
Merge branch '2.11.x' 2020-03-30 11:40:59 -07:00
David Lord
786867a47c
Merge pull request #1181 from bartfeenstra/async-namespace
Allow namespaces to be used in asynchronously rendered templates.
2020-03-30 11:34:13 -07:00
Bart Feenstra
0fd45a4dc7
namespace object works in async templates 2020-03-30 11:32:34 -07:00
David Lord
5f95471a68
Merge pull request #1178 from avli/fix-lexer-lineno
Fix tokens line number calculation when whitespace stripping is used
2020-03-30 11:23:11 -07:00
Andrey Lisin
77a212bf93
Fix tokens line number calculation when whitespace stripping is used 2020-03-30 11:11:07 -07:00
David Lord
c074fd5ecb
Merge branch '2.11.x' 2020-03-30 10:54:57 -07:00
David Lord
07b5c01338
Merge pull request #1182 from pallets/revert-package-loader
Revert dropping pkg_resources from PackageLoader for 2.11
2020-03-30 10:34:13 -07:00
David Lord
35a2ba5ef3
changelog for reverting PackageLoader changes 2020-03-30 10:31:42 -07:00
David Lord
e2357fad71
Revert "PackageLoader doesn't depend on setuptools"
This reverts commit 4b6077a8c0.
2020-03-30 10:11:22 -07:00
David Lord
cf53e2254d
Revert "PackageLoader understands namespace packages"
This reverts commit d2e0e78afe.
2020-03-30 09:55:51 -07:00
David Lord
41ed50c805
Merge pull request #1179 from pallets/undefined-recursion
AttributeError in undefined message doesn't cause RuntimeError
2020-03-27 10:05:12 -07:00
David Lord
f15452f130
AttributeError in undefined message doesn't cause RuntimeError 2020-03-27 09:51:53 -07:00
Joshua Bronson
b3a9df3072
Merge pull request #1174 from septatrix/patch-1
Fix html tag
2020-03-22 13:28:57 -04:00
Nils K
7c18c21fbf
Fix html tag 2020-03-22 17:58:20 +01:00
David Lord
e1b5e50ca3
Merge pull request #1163 from pallets/traceback-32-bit
better PyObject_HEAD size calculation
2020-02-28 19:08:10 -08:00
David Lord
40e70b820c
better PyObject_HEAD size calculation
fixes infinite loop on Python 3.6 32-bit
2020-02-28 19:00:51 -08:00
David Lord
eccf9a00a0
Merge pull request #1161 from ldealmei/patch-1
Add link to template designer documentation
2020-02-28 08:02:50 -08:00
ldealmei
930dd3d977
Add link to template designer documentation
For those who were actually looking for the template design documentation putting a link directly to it might prevent them to have to google for it. When on the API page, there is no direct way to find the template design documentation. Hope this can help others.
2020-02-28 08:00:07 -08:00
David Lord
45a76a3794
Merge branch '2.11.x' 2020-02-27 11:16:01 -08:00
David Lord
be0e0b02f5
Merge pull request #1160 from sivel/wordcount-soft-str
Use soft_str in do_wordcount, to trigger undefined
2020-02-27 11:10:31 -08:00
Matt Martz
ba080f51e0
use soft_str in do_wordcount, to trigger undefined 2020-02-27 11:06:35 -08:00
David Lord
2a70ef218b
Merge pull request #1149 from davidbrochart/fix_doc 2020-02-08 11:12:55 -08:00
David Lord
2f61f69de1
rewrite async discussion 2020-02-08 11:08:05 -08:00
David Brochart
7c1b535c35
Fix async doc 2020-02-08 11:08:04 -08:00
David Lord
e08dadd220
Merge branch '2.11.x' 2020-02-05 20:39:04 -08:00
David Lord
dd5a0508c5
remove custom pytest marks 2020-02-05 20:23:47 -08:00
David Lord
1164cc3617
fix formatting 2020-02-05 14:31:20 -08:00
David Lord
0166b4c8b8
fix formatting 2020-02-05 14:29:52 -08:00
David Lord
3915eb5c2a
Merge pull request #1136 from pallets/drop-python2
Drop Python 2
2020-02-05 08:50:01 -08:00
David Lord
27a5c4e0e3
add note about ugettext 2020-02-05 08:44:19 -08:00
David Lord
26d462a334
add pyupgrade pre-commit hook 2020-02-05 08:44:19 -08:00
David Lord
8468d3a98f
bump bytecode cache version 2020-02-05 08:44:19 -08:00
David Lord
2a8515d2e5
apply pyupgrade and f-strings 2020-02-05 08:44:15 -08:00
David Lord
42edc13290
stop building universal wheel 2020-02-05 08:37:40 -08:00
David Lord
60293416db
remove more compat code 2020-02-05 08:37:40 -08:00
David Lord
148a19138c
remove _compat module 2020-02-05 08:37:40 -08:00
David Lord
b0015c72d5
remove deprecated code 2020-02-05 08:37:40 -08:00
David Lord
e52b42d3ef
remove unsupported test envs 2020-02-05 08:37:40 -08:00
David Lord
f28b25ea62
remove Python 2 from docs 2020-02-05 08:37:40 -08:00
David Lord
0c75d48058
Merge branch '2.11.x' 2020-02-05 08:37:15 -08:00
David Lord
9fe06d8866
Merge pull request #1146 from tomaskrizek/stricter-getattr-checks
Use stricter getattr() checks for decorator functions
2020-02-04 09:01:50 -08:00
David Lord
04294999c7
add changelog and test 2020-02-04 08:57:39 -08:00
Tomas Krizek
9933324688
Use stricter getattr() checks for decorator functions
Explicit checks for "is True" prevents unexpected behaviour with objects
that are callable and have permissive gettatr(), such as Mock.

Fixes #1145
2020-02-04 08:37:58 -08:00
David Lord
b85283e846
release version 2.11.1 2020-01-30 10:05:29 -08:00
David Lord
547e6e39ec
Merge branch '2.11.x' 2020-01-30 09:56:19 -08:00
David Lord
3d5bfc6109
Merge pull request #1143 from pallets/bugfix/attribute-access
Fix attribute access in async code.
2020-01-30 09:54:44 -08:00
David Lord
d61c1ea70b
add changelog 2020-01-30 09:50:36 -08:00
Armin Ronacher
15d7e615f4
Added regression test for slicing of attributes 2020-01-30 09:40:14 -08:00
Armin Ronacher
05dee9b870
Fix attribute access in async code. Fixes #1141 2020-01-30 09:39:07 -08:00
David Lord
4ca745e6c8
remove unsupported test envs 2020-01-30 09:28:40 -08:00
David Lord
4b8d839e1e
start version 3.0.0 2020-01-27 13:51:27 -08:00
David Lord
bbdafe33ce
release version 2.11.0 2020-01-27 10:24:29 -08:00
David Lord
9ff27f64a9
add python 3.8 classifier, clean up changelog 2020-01-26 22:24:57 -08:00
David Lord
d312609ccd
isolate bytecode cache tests 2020-01-26 22:24:38 -08:00
David Lord
984997913c
import Markup from markupsafe, fix flake8 import warnings 2020-01-26 22:23:36 -08:00
David Lord
c6d864cf89
increment bytecode cache version 2020-01-26 22:22:11 -08:00
David Lord
c775bb9949
remove test and coverage results from ci 2020-01-26 22:21:08 -08:00
David Lord
15337f794a
Merge pull request #1133 from pallets/revert-rename
Revert "Rename to Jinja"
2020-01-26 21:22:29 -08:00
David Lord
86f1432cf8
Revert "rename directory to jinja"
This reverts commit eac9acb7ae.
2020-01-26 21:12:53 -08:00
David Lord
4a59ac9514
Revert "rename imports to jinja"
This reverts commit 1167525b73.
2020-01-26 21:12:52 -08:00
David Lord
4ec93a454b
Revert "add warning and alias for jinja2"
This reverts commit fc9c60ba45.
2020-01-26 21:12:47 -08:00
David Lord
8d85f9cb6b
extract jinja2-compat to separate repo 2020-01-10 16:54:34 -08:00
David Lord
457b59b719
Merge pull request #1121 from pallets/the-great-rename
Rename jinja2 to jinja
2020-01-10 16:15:25 -08:00
David Lord
fc9c60ba45
add warning and alias for jinja2 2020-01-10 15:30:16 -08:00
David Lord
1167525b73
rename imports to jinja 2020-01-10 15:30:16 -08:00
David Lord
eac9acb7ae
rename directory to jinja 2020-01-10 15:30:16 -08:00
David Lord
42d4a4e380
Merge pull request #1125 from pallets/style
move to src directory, add pre-commit
2020-01-10 15:12:20 -08:00
David Lord
51c1c8efa6
simplify module docstrings 2020-01-10 13:42:02 -08:00
David Lord
e492255f27
remove old scripts and examples 2020-01-10 12:58:38 -08:00
David Lord
143667d95d
add py 3.8 and style to tests 2020-01-10 12:44:39 -08:00
David Lord
126fce8b04
more relative imports
_identifier exports a compiled regex instead of a string to avoid some
tricky cleanup
2020-01-10 12:39:19 -08:00
David Lord
963b5d3c3f
ensure deprecation warnings mention version 2020-01-10 12:39:14 -08:00
David Lord
bb6216ea30
apply flake8 2020-01-10 10:40:52 -08:00
David Lord
04c8787155
apply black 2020-01-10 07:54:39 -08:00
David Lord
d177eeb295
apply reorder-python-imports 2020-01-10 07:54:39 -08:00
David Lord
c30675f964
add pre-commit config 2020-01-10 07:54:34 -08:00
David Lord
e1e1e7d18b
move to src directory 2020-01-09 10:38:52 -08:00
David Lord
8342180f39
Merge pull request #1117 from nvllsvm/fix_exc_pickle
Fix TemplateSyntaxError pickling
2020-01-08 12:09:37 -08:00
Andrew Rabert
b23a0dec2d
TemplateSyntaxError can be pickled 2020-01-08 11:14:52 -08:00
David Lord
715f357abc
Merge pull request #1122 from blueyed/vim-indent
ext/Vim/jinja.vim: minor fixes
2020-01-06 05:45:31 -08:00
David Lord
9b125f47d1
Merge pull request #1123 from blueyed/fix-typo
minor: fix typo in docstring
2020-01-06 05:45:09 -08:00
Daniel Hahler
390556c1a2 minor: fix typo in docstring 2020-01-06 14:31:04 +01:00
Daniel Hahler
d31e66c6ba ext/Vim/jinja.vim: fix issues reported by vint 2020-01-06 14:29:46 +01:00
Daniel Hahler
88023b8948 ext/Vim/jinja.vim: fix indent 2020-01-06 14:29:11 +01:00
David Lord
4fe03dafcd
Merge pull request #1115 from myii/patch-2
fix typo in templates.rst, "hat" to "that"
2019-12-08 07:07:29 -08:00
Imran Iqbal
13ff6c8c1d
fix(templates.rst): fix typo (hat => that) 2019-12-08 14:21:03 +00:00
David Lord
f81c74437e
Merge pull request #1114 from pallets/import-undefined
handle Undefined in get/select_template
2019-12-05 13:50:42 -08:00
David Lord
2ec62dc414
handle Undefined in get/select_template 2019-12-05 13:46:36 -08:00
David Lord
9176fbd818
Merge pull request #1113 from pallets/namespace-loader
PackageLoader understands namespace packages
2019-12-05 07:25:11 -08:00
David Lord
d2e0e78afe
PackageLoader understands namespace packages 2019-12-05 07:06:09 -08:00
David Lord
28f12c020e
Merge pull request #1112 from pallets/include-syntax-error-source
TemplateSyntaxError from included template has source
2019-12-03 13:25:57 -08:00
David Lord
2b0d1ed921
TemplateSyntaxError from included template has source 2019-12-03 13:22:10 -08:00
David Lord
09ddf2db43
Merge pull request #1111 from pallets/optimizer-nodes
apply optimizer to all Expr nodes
2019-12-03 09:13:39 -08:00
David Lord
d4aff1fc0b
apply optimizer to all Expr nodes 2019-12-03 09:08:37 -08:00
David Lord
06238a9dba
Merge pull request #861 from OddBloke/contextreference_locals
Add a DerivedContextReference node type
2019-12-02 14:07:08 -08:00
Daniel Watkins
1539dd418a
add a node for derived context references
This allows extensions to access locals in the scope from which they
were called.
2019-12-02 14:03:12 -08:00
David Lord
41df8a503b
Merge pull request #1110 from pallets/patch-traceback
rewrite traceback rewriting support
2019-12-02 13:07:56 -08:00
David Lord
cfb789adc8
rewrite traceback rewriting support
Simplify the `jinja.debug` code.

On Python >= 3.7, `tb_next` is directly assignable. On PyPy, use
transparent proxies only if support is enabled. For cpython < 3.7, use
ctypes to set `tb_next`. Rewrite the ctypes code to use `py_object` and
`pythonapi.Py_IncRef`, which seems to avoid crashing on debug builds.

On Python 3, a rewritten `TemplateSyntaxError` would retain the frames
from the compiler functions for some reason. Clear these so the template
source is the last thing in the traceback.
2019-12-02 12:58:18 -08:00
David Lord
6c1a62f777
Merge pull request #1109 from pallets/visit-output-refactor
refactor visit_Output
2019-11-20 14:44:22 -08:00
David Lord
3487c8e087
refactor visit_Output
* `finalize` is generated once and cached for all nodes.
* Extract common behavior for native env.

Removed the compiler behavior where groups of nodes would generate a
format string. Instead, individual nodes are always yielded. This made
rendering 30% faster in the examples, and simplifies the code. It also
removes the issue where Python would report either the first or last
line of the multi-line format expression, messing up the traceback line
number mapping.
2019-11-20 14:09:44 -08:00
David Lord
5d33f673ce
Merge pull request #1105 from areebbeigh/issue-1102
nodes.py: Return on first false in Compare() expr
2019-11-20 06:58:20 -08:00
David Lord
1f37d5f0d4
add test and changelog for constant comparison folding 2019-11-20 06:55:16 -08:00
areebbeigh
48036fb4cb
return on first false when folding Compare node 2019-11-20 06:23:23 -08:00
David Lord
c206cc987e
Merge pull request #1108 from captainmalloc/runtime_calls
Use 'callable' instead of typechecking for runtime calls ctx/env injection
2019-11-20 06:22:40 -08:00
Adriano Scoditti
70ea1d3e22
use 'callable' instead of typechecking to inject context 2019-11-20 06:16:05 -08:00
David Lord
540b260198
Merge pull request #1101 from pallets/refactor-loop-context
don't prefetch next item in loop context
2019-11-08 07:13:53 -08:00
David Lord
4d0949b308
async templates await attribute access 2019-11-07 19:05:16 -08:00
David Lord
24d86a9615
don't prefetch next item in loop context 2019-11-07 13:35:57 -08:00
David Lord
d8820b95d6
Merge pull request #1098 from pallets/urlencode-docs
clarify quoting behavior of urlencode filter
2019-11-04 08:50:13 -08:00
David Lord
d988c13ffa
clarify quoting behavior of urlencode filter 2019-11-04 08:46:21 -08:00
David Lord
77aa538b68
Merge pull request #829 from aogier/feature/550-hyphens-wordwrap
Exposing Textwrapper break_on_hyphens option to wordwrap filter
2019-11-01 08:40:50 -07:00
Alessandro -oggei- Ogier
2edcf7db4b
add break_on_hyphens parameter to wordwrap filter 2019-11-01 08:35:01 -07:00
David Lord
881c56b6c4
Merge pull request #766 from fheinle/palletes_jinja_175-wordwrap
Let wordwrap filter respect existing newlines
2019-11-01 08:11:55 -07:00
David Lord
f6e539831f
reformat, doc, and test for wordwrap 2019-11-01 08:08:38 -07:00
Florian Heinle
4e7e45ab35
let wordwrap filter respect existing newlines
textwrap.wrap() has unexpected behaviour where when wrapping multiple
paragraphs it will not consider existing newlines.

I.e. when your first paragraph ends on col 75, the next paragraph
will be wrapped on col 5 already.

This patch is wrapping each line individually and combining it back
together.
2019-11-01 07:56:03 -07:00
David Lord
5dcc676e88
Merge pull request #673 from MrSenko/get_corresponding_lineno_traceback
handle template.get_corresponding_lineno() for lines without debug info
2019-11-01 06:22:27 -07:00
David Lord
abc6ac82b7
Merge pull request #1096 from pallets/compile-encoding
compile writes utf8
2019-10-28 09:45:30 -07:00
David Lord
1db7d51366
compile writes utf8 2019-10-28 09:39:37 -07:00
David Lord
848809089c
Merge pull request #1095 from pallets/native-template-env
creating a NativeTemplate creates a NativeEnvironment
2019-10-28 09:06:00 -07:00
David Lord
32027ea0e6
creating a NativeTemplate creates a NativeEnvironment 2019-10-28 09:00:01 -07:00
David Lord
4c95c5f5f0
Merge pull request #1093 from cclauss/print-function
Use print() function in both Python2 and Python 3
2019-10-28 06:50:55 -07:00
cclauss
82a8ea4f3b Use print() function in both Python2 and Python 3 2019-10-27 13:05:59 +01:00
David Lord
9a7dd7b28b
Merge pull request #1090 from pallets/lrucache-copy
LRUCache.copy's queue methods point to the correct queue
2019-10-24 08:00:39 -07:00
David Lord
7ca03082c5
don't create a third queue 2019-10-24 07:54:38 -07:00
Ryan Siemens
39d2e2254a
LRUCache.copy initializes queue methods 2019-10-24 07:47:20 -07:00
David Lord
81825095d2
use "Jinja" instead of "Jinja2" 2019-10-23 13:35:49 -07:00
David Lord
1af1205a9c
Merge pull request #1087 from pallets/jinja-name
use "Jinja" instead of "Jinja2"
2019-10-23 12:40:55 -07:00
David Lord
57626a000a
use "Jinja" instead of "Jinja2" 2019-10-23 12:35:53 -07:00
David Lord
6e50bbd9f7
Merge pull request #1086 from pallets/native-string-literal
preserve quotes between nodes in native env
2019-10-22 13:33:24 -07:00
David Lord
e5c042bb7f
preserve quotes between nodes in native env 2019-10-22 12:58:17 -07:00
David Lord
afd6c48308
Merge pull request #1064 from alexwlchan/support-pathlib
Support paths created with pathlib in FileSystemLoader and ModuleLoader
2019-10-21 07:41:01 -07:00
David Lord
b43531f8d8
use fspath instead of str 2019-10-21 07:37:26 -07:00
Alex Chan
12307960dc
support pathlib in FileSystemLoader and ModuleLoader 2019-10-21 06:13:58 -07:00
David Lord
29d1ff4119
Merge pull request #1085 from pallets/docs-cycler
clarify cycler.next() behavior
2019-10-20 16:50:28 -07:00
David Lord
cde8a42fd6
clarify cycler.next() behavior 2019-10-20 16:42:14 -07:00
David Lord
1b3d6ed538
Merge pull request #1084 from pallets/i18n-docs
clean up i18n documentation
2019-10-19 08:08:56 -07:00
David Lord
50f181080a
clean up i18n documentation
explain enabling newstyle
organize newstyle advantages
mention escaping percent signs for formatting
mention marking format parameters as safe
fix newstyle ref
2019-10-19 08:04:23 -07:00
David Lord
91893a4727
Merge pull request #1083 from pallets/docs-changes
Address various documentation requests
2019-10-18 12:25:27 -07:00
David Lord
f9f1e3d8b2
document equivalent generator expressions for filters
closes #1068
2019-10-18 12:19:03 -07:00
David Lord
f91db0b56f
document how ContextReference relates to contextfunction
closes #762
2019-10-18 12:03:33 -07:00
David Lord
edc0aa2264
document formatting methods in format filter
closes #566
2019-10-18 11:53:33 -07:00
David Lord
36ba250202
document lack of file extension
closes #547
2019-10-18 11:37:37 -07:00
David Lord
aad4dcfc0f
document behavior of block tag in if block
closes #423
2019-10-18 11:31:06 -07:00
David Lord
a554288475
format expression docs 2019-10-18 11:23:59 -07:00
David Lord
d2bf582175
improve docs about string methods in templates
closes #273
2019-10-18 11:20:25 -07:00
David Lord
1949a5cf6c
Merge pull request #1082 from pallets/pkgutil-loader
PackageLoader doesn't depend on setuptools
2019-10-17 11:17:24 -07:00
David Lord
4b6077a8c0
PackageLoader doesn't depend on setuptools 2019-10-17 11:08:19 -07:00
David Lord
81b32242e5
Merge pull request #993 from aayushuppal/loop_fix
Fix for Loop properties revindex and revindex0 still wrong in Jinja2 2.10 #794
2019-10-14 09:16:59 -07:00
aayushuppal
ef1a4c698c
fixing LoopContext, loops indexing and iterator length property 2019-10-14 09:11:13 -07:00
David Lord
468b2df4c1
reformat changelog 2019-10-14 07:03:03 -07:00
David Lord
8146e45b30
Merge pull request #1079 from ThiefMaster/cond-expr-undefined
Use separate undefined object for else-less conditional expressions
2019-10-13 10:00:36 -07:00
Adrian Moennich
4d331a0ae3 Don't make cond_expr_undefined configurable 2019-10-13 16:54:35 +02:00
Adrian Moennich
c4d39969e2 Use separate undefined object for CondExpr 2019-10-13 16:32:02 +02:00
David Lord
464e4934d1
Merge pull request #1081 from pallets/open-if-exists
skip template with same name as directory
2019-10-13 06:48:54 -07:00
David Lord
aaf13a231c
skip template with same name as directory
When using multiple paths with FileSystemLoader, a template with the
same name as a directory will not prevent loading a template in the
directory.
2019-10-13 06:42:44 -07:00
David Lord
0687adfa86
Merge pull request #1080 from pallets/no-finalize-template-data
don't finalize TemplateData nodes
2019-10-12 21:34:11 -07:00
David Lord
719537aeec
don't finalize TemplateData nodes
Finalize only applies to the output of expressions (constant or not).
Add tests for context, eval, and env finalize functions.
2019-10-12 21:25:48 -07:00
David Lord
636c7122d9
consistent use of token constants 2019-10-10 08:50:20 -07:00
David Lord
81d526df96
Merge pull request #1077 from pallets/pytest-cleanup
Pytest cleanup
2019-10-10 07:14:15 -07:00
David Lord
9ca80538d9
fix invalid double extends test 2019-10-10 06:57:04 -07:00
Kevin Brown
ca72c5f301 Replaced try...catch within tests with pytest.raises
This still leaves one in test_debug which relies on reading out
the traceback and cannot easily be replaced by pytest.raises
like the others.
2019-10-10 02:32:29 -04:00
David Lord
0b9d252a07
Merge pull request #824 from dagwieers/new-type-tests
Add more strict type tests
2019-10-09 20:09:42 -07:00
Dag Wieers
9bd3cb22c1
Add more strict type tests
This PR adds a few more type-related tests.

- boolean
    Testing of an object is a boolean required 2 tests.

- false
    Make this similar to testing none value

- true
    Make this similar to testing none value

- integer
    The existing 'number' test does not make a distinction between
    integer, float or even booleans

- float
    The existing 'number' test does not make a distinction between
    integer, float or even booleans
2019-10-09 20:02:28 -07:00
David Lord
9aa8296781
Merge pull request #1073 from brtomas0/master
changed test_join functions to unique names
2019-10-09 16:38:54 -07:00
Brandon Tomás
c76f035e85 changed test_join functions to unique names 2019-10-09 19:14:03 -04:00
David Lord
6cc49a789a
Merge pull request #1072 from pallets/autoescape-docs
explain what autoescaping does
2019-10-08 14:15:37 -07:00
David Lord
b26eabe52d
explain what autoescaping does 2019-10-08 14:11:59 -07:00
David Lord
6b9eb6df5a
use slots for lexer lstrip marker 2019-10-07 10:11:00 -07:00
David Lord
0a4dad6031
add changelog for #938 2019-10-07 07:42:04 -07:00
David Lord
f1d199a84d
Merge pull request #938 from stevenorum/master
Fixing compiler handling of parens around boolean comparisons.
2019-10-07 06:55:32 -07:00
David Lord
c8b1b020c0
add changelog for #858 2019-10-06 23:42:36 -07:00
David Lord
562e1782ce
Merge pull request #858 from exponea/857-lexer-whitespace-performance
Fix lexer being extremely slow on large amounts of whitespace. Fixes #857
2019-10-06 23:41:04 -07:00
David Lord
37249c0810
add comments about lstrip code 2019-10-06 23:37:16 -07:00
David Lord
7cf0e6d69e
Merge branch 'master' into 857-lexer-whitespace-performance 2019-10-06 23:28:18 -07:00
David Lord
381d72ace1
Merge pull request #1071 from btharper/pytest-raises
Eliminate dead code by using pytests.raises instead of try/except/else
2019-10-05 21:20:38 -07:00
btharper
051b5217bf Eliminate dead code by using pytests.raises instead of try/except/else 2019-10-06 00:00:24 -04:00
David Lord
3ea88fe752
Merge pull request #983 from kevin-brown/pr/798
Add support for a {% debug %} extension tag.
2019-10-04 19:17:41 -07:00
David Lord
5e645ab25c
document debug extension 2019-10-04 19:13:39 -07:00
David Lord
93565e6cd8
don't bypass autoescape 2019-10-04 19:13:31 -07:00
Shaheed Haque
017c8d3509
Add support for a {% debug %} extension tag.
This dumps the available variables, filters and tests.
2019-10-04 13:15:20 -07:00
David Lord
496c81af81
Merge pull request #1047 from lfdebrux/ldeb-bug-chainable_undefined_and_markup
Fix bug with when using Markup on ChainableUndefined
2019-10-04 13:11:20 -07:00
Laurence de Bruxelles
8afc7e57c9
Fix bug with when using Markup on ChainableUndefined
Wrapping a ChainableUndefined object with Markup causes an
UndefinedError because Markup thinks that ChainableUndefined has an
attribute called __html__ and tries to call it.

This commit fixes this by defining a method __html__ that calls
ChainableUndefined.__str__. We also add a regression test.
2019-10-04 13:06:12 -07:00
David Lord
e68d9b8705
Merge branch '2.10.x' 2019-10-04 12:53:44 -07:00
David Lord
03ce2ce772
Merge pull request #1070 from anowlcalledjosh/develop
Fix incorrect release date for 2.10.3
2019-10-04 12:51:47 -07:00
Josh Holland
b5adc65c22
Fix incorrect release date for 2.10.3 2019-10-04 12:44:46 -07:00
David Lord
f179cf8c71
Merge pull request #828 from chamini2/trim-more
Add chars option to trim
2019-10-04 12:01:37 -07:00
David Lord
544c2e9501
Merge branch '2.10.x' 2019-10-04 11:59:18 -07:00
David Lord
c6a71f9545
release version 2.10.3 2019-10-04 11:50:02 -07:00
Adrian
218e77d77d
Fix typo in setup.py 2019-10-04 20:46:10 +02:00
Matteo Ferrando
9a5d522cb5
add chars option to trim 2019-10-04 11:46:04 -07:00
David Lord
38165dfeba
Merge branch '2.10.x' 2019-10-04 11:22:50 -07:00
David Lord
0fee409131
release version 2.10.2 2019-10-04 11:18:56 -07:00
David Lord
65da441ee7
update project metadata 2019-10-04 11:17:12 -07:00
David Lord
d3b976b7f8
Merge pull request #1000 from EtiennePelletier/fix_deadlock_improve_tests
Fix deadlock in LRUCache and improve test coverage
2019-10-04 08:30:39 -07:00
EtiennePelletier
69d8d98860
Add tests for Undefined classes 2019-10-04 08:25:36 -07:00
EtiennePelletier
53a5d0aa44
Add tests for utils.py - LRUCache, Lorem Ipsum & + 2019-10-04 08:25:34 -07:00
EtiennePelletier
065b58fc74
Prevent deadlock in LRUCache.setdefault
setdefault was acquiring write_lock, then calling getitem and also
potentially setitem, which also both try to acquire the write lock.
2019-10-04 07:58:58 -07:00
David Lord
71133493b5
Merge pull request #1040 from minho42/Simplify-import-split
Simplify splitting import_name in import_string()
2019-10-04 07:42:43 -07:00
Joshua Bronson
cc89256326
Merge pull request #1065 from alexwlchan/add-pypi-links
Add docs, code and issue tracker links to setup.py
2019-09-22 15:29:08 -04:00
Alex Chan
beb1fc6dbc Add docs, code and issue tracker links to setup.py 2019-09-22 09:52:15 +01:00
Joshua Bronson
31d48f3e48
Merge pull request #1063 from PikachuEXE/fix/manifest
Fix MANIFEST.in to include renamed license file
2019-09-19 22:28:44 -04:00
PikachuEXE
d7f892c1ed Fix MANIFEST.in to include renamed license file 2019-09-20 10:16:11 +08:00
Tim Gates
91a404073a Fix simple typo: problemtic -> problematic (#1059)
Plus rephrase the comment for greater clarity.
2019-09-04 18:12:07 -04:00
David Lord
436f00b776
Merge branch '2.10.x' 2019-09-04 08:25:09 -07:00
David Lord
72fffe41a2
Merge pull request #1051 from vstinner/tb_next_py37
Fix TracebackFrameProxy.set_next() on Python 3.7
2019-09-04 07:48:06 -07:00
Victor Stinner
3a86ef3d72
Fix TracebackFrameProxy.set_next() on Python 3.7
Fix issue #1050: fix a crash in TracebackFrameProxy.set_next() on
Python 3.7 and newer, when Python is build in debug mode.

Since Python 3.7, traceback.tb_next field can be modified: ctypes is
no longer needed.
2019-09-04 07:40:52 -07:00
Joshua Bronson
274eff178d
Merge pull request #1045 from yuriks/patch-1
Update PyPI link to point to Jinja2 instead of 1
2019-08-08 22:49:09 -04:00
Yuri Kunde Schlesner
2231a5fffe
Update PyPI link to point to Jinja2 instead of 1 2019-08-08 17:14:03 -07:00
David Lord
9550dc85ff
Merge branch '2.10.x' 2019-07-26 15:21:16 -07:00
David Lord
d601b3f496
fix tox docs build 2019-07-26 15:17:58 -07:00
David Lord
288dd42f57
Merge branch '2.9.x' into docs 2019-07-26 15:01:03 -07:00
David Lord
908726cd81
Merge pull request #1042 from pallets/docs
modernize docs, 2.9.x branch
2019-07-26 14:39:59 -07:00
David Lord
90756da7b6
reformat readme 2019-07-26 14:36:55 -07:00
David Lord
06696563d7
fix linkcheck issues 2019-07-26 12:12:41 -07:00
David Lord
f77b09d998
modernize docs config, use pallets-sphinx-themes 2019-07-26 11:41:08 -07:00
Min ho Kim
0209b0fc62 Fix typo 2019-07-25 15:29:57 +02:00
Min ho Kim
486a2f4afa Simplify splitting import_name in import_string() 2019-07-24 09:55:04 +10:00
David Lord
9a877fa6c7
Merge pull request #1035 from utoddl/stable-sort-doc
document that sort is stable
2019-07-23 15:23:03 -07:00
David Lord
8a4a13d456
clean up sort filter docs 2019-07-23 15:20:07 -07:00
Todd Lewis
996bcadc3e
document that sort is stable 2019-07-23 14:56:49 -07:00
David Lord
47e5c95dbb
Merge pull request #956 from revelt/patch-1
Tweak docs grouper chapter
2019-07-23 14:54:57 -07:00
David Lord
d8f1eb1cf6
clean up groupby filter docs 2019-07-23 14:49:06 -07:00
Roy Revelt
523be83aec
clarify groupby behavior in docs 2019-07-23 14:49:06 -07:00
David Lord
8e3c0e7739
Merge pull request #923 from CleoQc/feature/long_integer_with_underscores
Feature/long integer with underscores
2019-07-23 11:11:28 -07:00
David Lord
733851eda0
clean up numeric underscore support
add changelog
clean up docs
parametrize tests
explain float regex
2019-07-23 11:07:09 -07:00
CleoQc
1fea4b65f9
support underscore in int and float 2019-07-23 09:25:16 -07:00
David Lord
278a0574f7
Merge pull request #922 from CleoQc/feature/support_scientific_notation
Feature/support scientific notation
2019-07-23 08:35:15 -07:00
David Lord
483b62eec2
clean up scientific notation support
add changelog
clean up docs
parametrize tests
2019-07-23 08:19:51 -07:00
CleoQc
fd00805ca7
support scientific notation 2019-07-22 12:27:56 -07:00
David Lord
626bdd08d4
Merge pull request #961 from JulienPalard/TemplateNotFound
Better repr for TemplateNotFound.
2019-07-22 10:50:37 -07:00
David Lord
5b2b7cab37
Merge pull request #981 from pwlandoll/2.10.x
Add Links section to README
2019-07-22 10:47:32 -07:00
David Lord
2e950f0f5f
Merge pull request #994 from bkiu/931-undeclared-variables
exclude globals from find_undeclared_variables
2019-07-22 10:46:50 -07:00
Brendan
f7b110cbd0
exclude globals from find_undeclared_variables 2019-07-22 10:43:47 -07:00
David Lord
c5f1fd328b
Merge pull request #985 from bkiu/557-map-default
Adding a default parameter to builtin map filter
2019-07-22 10:39:23 -07:00
David Lord
81783615ea
Merge branch 'master' into 557-map-default 2019-07-22 10:30:10 -07:00
Brendan
8b09b03aa0
Adding a default parameter to builtin map filter 2019-07-22 09:43:13 -07:00
David Lord
219b8a33b1
Merge pull request #986 from pbjr23/fix-safe-range-memory
Fix memory usage bug in Python 2 by using correct version of range
2019-07-22 08:34:09 -07:00
Prakhar Bhandari
35fcd9fef2
sandbox uses xrange on Python 2 2019-07-22 08:30:22 -07:00
David Lord
04cc41ea1e
Merge pull request #990 from tbnorth/vim_syntax_tweak
This is the correct thing to do, vim-wise, although whether
2019-07-22 07:55:11 -07:00
David Lord
52c45df292
Merge pull request #1018 from kbiggers/jinja/557
add default to map filter
2019-07-22 07:42:04 -07:00
Kevin
2319cd5409
add default to map filter 2019-07-22 07:38:50 -07:00
David Lord
f76c3edf2b
Merge pull request #1014 from markroth8/mroth/fix/748
Allow '{%+' to be valid syntax (but NOP) when lstrip_blocks == False. Fixes #748
2019-07-20 14:23:53 -07:00
Mark Roth
1e71e31512
Allow '{%+' to be valid syntax (but NOP) when lstrip_blocks == False. Fixes #748. 2019-07-20 14:18:56 -07:00
David Lord
55cb0e73e6
Merge pull request #1022 from jdufresne/hl
Correct syntax highlighting of jinja block in docs
2019-07-20 14:14:41 -07:00
Jon Dufresne
01af178323
Correct syntax highlighting of jinja block in docs 2019-07-20 14:10:02 -07:00
David Lord
13cc9f410c
Merge branch '2.10.x' 2019-07-20 14:03:04 -07:00
David Lord
e74640b5f3
Merge pull request #1030 from rillian/PytestUnknownMarkWarning
Fix pytest unknown mark warnings
2019-07-20 13:58:04 -07:00
David Lord
6661be0899
warnings are errors during tests 2019-07-20 13:56:23 -07:00
Ralph Giles
c61b366c02
Register custom test category markers.
Since around pytest 3.6 it's been possible to register custom
markers, and since version 4.5.0 pytest warns about any which
are not registered. Register a list of such markers, extracted
from those warnings, so they don't clutter the test output.
2019-07-20 13:53:54 -07:00
David Lord
94cecd4892
ignore coverage parse errors
Azure has Python 2.7.15 and Python 3.5.5, which can't parse async code.
Later patch versions can parse it fine, so this can be removed if
Azure updates.
2019-07-20 13:52:19 -07:00
David Lord
d04d9998d3
switch tests to azure pipelines 2019-07-20 12:44:26 -07:00
David Lord
6257019870
Merge pull request #1025 from pallets/unpin-pytest
Unpin Pytest on master branch
2019-07-20 12:22:17 -07:00
David Lord
ac6131d9b7
standardize license 2019-07-17 08:01:46 -07:00
Joshua Bronson
719c9f1f69
Merge pull request #1031 from minho42/Fix-typo
Fix typo
2019-07-07 11:36:01 -04:00
Min ho Kim
911df8e792 Fix line length 2019-07-08 00:12:52 +10:00
Min ho Kim
55e4a13075 Apply suggestions 2019-07-07 23:07:29 +10:00
Min ho Kim
99f2a6c6e5 Fix typo 2019-07-07 09:38:28 +10:00
Kevin Brown
5b3d0c3d54
Merge pull request #975 from kevbroch/master
add list filter to make example match output
2019-06-24 20:37:30 -04:00
Kevin Brown
88f2025e6e
Merge pull request #1002 from eplata31/bugfix-template-parse-if-with-dict-subproperty
BUGFIX #930 - Template parse if with when referencing with dictionary…
2019-06-24 20:32:11 -04:00
Kevin Brown
321b499778
Merge pull request #1013 from mayuropensource/jinja-670-sort-multi-attr
Add ability to specify multiple attributes in sort
2019-06-24 20:19:36 -04:00
Kevin Brown
1a33d44a09 Unpin pytest in tox.ini
This was "temporarily" pinned many months back, given that this is not pinned on the stable branch and tests appear to be passing, we should be able to remove it here.
2019-06-24 20:07:01 -04:00
Joshua Bronson
6ffe6cc970
Merge pull request #1021 from jdufresne/the-the
Fix typo "the the"
2019-06-21 19:47:51 -04:00
Jon Dufresne
aae91f42d1 Fix typo "the the" 2019-06-21 11:24:08 -07:00
David Lord
0f5f2010bb
Merge pull request #1019 from jbarreneche/backport-python3.7-collections-warning-fix
Backport python3.7 collections warning fix
2019-06-18 08:22:01 -07:00
Juan Barreneche
4b1cae9c60 Add python 3.7 deprecation warning fix to changelog 2019-06-18 10:51:55 -03:00
Florian Bruhin
593ee1e481 Import abstract base classes from collections.abc
In Python 3.7, importing ABCs directly from the `collections` module shows a
warning (and in Python 3.8 it will stop working) - see
c66f9f8d39

This fixes various DeprecationWarnings such as those:

```
.../jinja2/utils.py:485: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import MutableMapping

.../jinja2/runtime.py:318: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import Mapping
```
2019-06-18 10:45:22 -03:00
mayur-srivastava
5dea3f7d9b Refactor _prepare_attribute_parts() to use in both make_attrgetter() and make_multi_attrgetter() 2019-06-09 09:35:29 -04:00
Joshua Bronson
4ce2449a4c
Merge pull request #1009 from shamsimam/doc-python-methods
adds documentation on use of python methods in expressions
2019-06-05 23:25:47 -04:00
Joshua Bronson
22e0bfc247
Merge pull request #1012 from yongbozhang/issue-423
Remind not to put block in if statements in doc
2019-06-05 23:17:55 -04:00
Joshua Bronson
7798e7964f
Merge pull request #1015 from jab/pr-1011
Document nested extends and super.super().
2019-06-05 23:12:50 -04:00
jab
a811d86acc Fix "duplicate object description of jinja2" warning
Follow suggestion to use :noindex: for the instance in api."
2019-06-05 23:04:36 -04:00
jab
72e55739ef Improve nested extends (super.super) example. 2019-06-05 22:40:08 -04:00
Scott Crosby
b5c6c9c39d Write a new documentation section on nesting extends. 2019-06-05 22:39:59 -04:00
yongbozhang
273d8b184d issue-423 remind not to put block in if statements in doc 2019-06-02 16:27:55 -04:00
David Lord
7a6f97cee2
Merge pull request #1010 from dvamin/master
docs: Python3-ize the examples
2019-05-31 17:01:21 -04:00
mayur-srivastava
8a39ecae15 Add ability to specify multiple attributes in sort,
e.g. foo|sort(attribute='name,id').

This fixes #670
2019-05-31 16:50:15 -04:00
Deepak Amin
4965facc02 docs: Python3-ize the examples
This commit updates the examples to conform to Python 3 instead
of Python 2, as Python 3 is more acceptable these days.
2019-05-31 16:12:33 -04:00
Shams Imam
e632dc5f1b adds documentation on use of python methods in expressions 2019-05-31 14:18:45 -05:00
David Lord
a486b37458
Merge pull request #1008 from gokcegrbl/GH-999
Added new method itervalues() to LRUCache and deprecated itervalue()
2019-05-31 13:15:03 -04:00
gokcegrbl
90595070ae Added new method itervalues() to LRUCache and deprecated itervalue()
(Fixes pallets/jinja#999)
2019-05-31 12:28:44 +00:00
David Lord
30685be089
Merge pull request #1004 from myii/patch-1
docs(filters): fix typo `columwrapper` => `columnwrapper`
2019-05-21 07:50:07 -07:00
Imran Iqbal
62ca10664f
docs(filters): fix typo columwrapper => columnwrapper 2019-05-20 13:19:08 +01:00
David Lord
c4813e51ad
Merge pull request #1003 from flexferrum/master
Remove duplicated testcase
2019-05-17 06:33:37 -07:00
Flex Ferrum
e622e8997a
Remove duplicated testcase 2019-05-16 13:54:05 +03:00
eplata31
9b38bb434a BUGFIX #930 - Template parse if with when referencing with dictionary subproperty 2019-05-13 15:46:41 -05:00
Kevin Brown
67e2542dd4
Merge pull request #988 from tbnorth/triv_docs_link
fixes #242, deletes link to Jinja 1 docs.
2019-05-11 17:43:03 -04:00
Étienne Pelletier
19133d4059 Add ChainableUndefined allowing getattr & getitem (#997)
* Add ChainableUndefined allowing getattr & getitem

Allows using default values with chains of items or attributes that may
contain undefined values without raising a jinja2.exceptions.UndefinedError.

>>> import jinja2
>>> env = jinja2.Environment(undefined=jinja2.ChainableUndefined)
>>> env.from_string("{{ foo.bar['baz'] | default('val') }}").render()
'val'

* Remove class decorator from ChainableUndefined
2019-05-08 10:47:33 -04:00
Kevin Brown
323e8928e8 Add new maintenance branch format to Travis (#987)
* Added new maintenance branch format to Travis

The maintenance branch format appeared to change from
`[version]-maintenance` to `[version].x` in the recent months, and
this broke Travis CI builds made to those branches. Because they
no longer meet the branch regex, the pull requests builds against
these branches were no longer being run.

This ads the regex for any branch which ends in `.x`, which should
catch the new pattern for maintenance branches.

* Use the branch regex from werkzeug

This is more specific to only catch version number branches.

* Sync with master

Apparently the build configuration for this branch is very old and doesn't match master at all.
2019-05-07 10:38:32 -04:00
David Lord
9766c179fa
Merge pull request #989 from LindsayYoung/patch-1
Create CODE_OF_CONDUCT.md
2019-05-06 15:41:36 -04:00
Terry N. Brown
b02c3ee895 This is the correct thing to do, vim-wise, although whether
it has any impact depends on how the user has folding set up
in vim. I confirmed that with the change, a folding setup that
uses these variables works, whereas without the change, the same
setup doesn't work.

Change only effects a file that has to be manually copied to the user's
~/.vim/syntax folder, so it won't impact jinja execution in any way.
2019-05-06 15:29:48 -04:00
Lindsay Young
8affe2b8e5
Create CODE_OF_CONDUCT.md
Ticket is referenced in [#Issue 1](https://github.com/pallets/meta/issues/1) in the Meta repo.
I spoke with @davidism and the decision was to use Contributor Covenant. It has easy GitHub integration and quality content.
2019-05-06 13:10:17 -04:00
Terry N. Brown
6373e25f80 fixes #242, deletes link to Jinja 1 docs.
This just fixes a broken link by deleteing it.

I'm assuming Jinja 1 docs. aren't readily available anymore.
I looked for a git tag for version 1 as an alternative target,
but didn't see that either.
2019-05-06 12:33:13 -04:00
Raul Tambre
888dc8d81a Fix use of 'is' operator for comparison
The 'is' operator is not meant to be used for comparisons. It currently working is an implementation detail of CPython.
CPython 3.8 has added a SyntaxWarning for this.
2019-05-06 18:11:06 +02:00
Peter Dolak
7d00a40465 Fix lexer being extremely slow on large amounts of whitespace. Fixes #857 2019-05-06 11:38:08 -04:00
David Lord
e2140487aa
Merge remote-tracking branch 'origin/2.10.x' 2019-05-06 07:24:46 -07:00
David Lord
64b44589fb
Merge pull request #982 from kevin-brown/sphinx-upgrade
Fix tox docs-html builds
2019-05-06 10:24:09 -04:00
Kevin Brown
722ee98729 Fix tox docs-html builds
These have been broken for about a month now because of the upgrade
to Sphinx 2. This upgrade happened automatically because we do not
have the version pinned.

Luckily this issue appears to only be from having Python 2 syntax in
the docs script, so making that compatible with Python 3 fixes the
error and allows the docs to pass.
2019-05-06 10:07:48 -04:00
Peter Landoll
2fb7a4a30f Add Links section to README 2019-05-06 10:01:39 -04:00
Kevin Broch
98dc54dff4 add list filter to make example match output 2019-04-29 11:26:33 -07:00
David Lord
fd89fed745
Merge branch '2.10.x' 2019-04-06 13:12:56 -07:00
David Lord
c4c4088945
release 2.10.1 2019-04-06 11:02:53 -07:00
Armin Ronacher
a2a6c930bc
sandbox str.format_map 2019-04-06 10:50:47 -07:00
Julien Palard
a7493f4c92 Better repr for TemplateNotFound. 2019-03-18 16:19:13 +01:00
Armin Ronacher
7e417c5c6e
Update CHANGES.rst 2019-02-18 08:15:10 +01:00
seaders
2b23cca8cf Await in async version of the map filter (#913) 2019-02-18 08:14:47 +01:00
David Lord
6e08416ce2
Merge pull request #943 from RubenGarcia/master
Fix typo
2019-02-08 05:09:29 -08:00
Ruben Garcia
a9d557f6fa Fix typo 2019-02-08 11:18:06 +01:00
Steve Norum
eca6fbfd6f Fixing compiler handling of parens around boolean comparisons. 2019-01-12 11:39:49 -05:00
David Lord
9fe9520f2d
Merge pull request #932 from jdufresne/py37
Add testing and document support for Python 3.7 & pypy3
2018-12-08 10:32:39 -08:00
Jon Dufresne
1b55cb7a45 Add testing and document support for Python 3.7 & pypy3 2018-12-08 10:07:56 -08:00
David Lord
dd6c76599c
Merge pull request #929 from ExplodingCabbage/fix-nl2br
Fix broken nl2br filter example
2018-11-25 10:54:43 -08:00
Mark Amery
9e410c7b04 Fix broken nl2br filter example
This example attempts to handle both Windows-style and Unix-style line endings, but does it wrong; as noted at https://stackoverflow.com/q/12521127/1709587, the regex here will match a single \r\n as if it were a double line-break, which results in all single Windows-style line-breaks getting converted into <p> breaks instead of <br> breaks as intended.

This patch fixes that by applying Alan Moore's proposed fix from https://stackoverflow.com/a/12521544/1709587 of using a negative lookahead so that a \r cannot be counted as a line break if it is followed by a \n (while still allowing the \r\n combination to count as a line break).
2018-11-25 17:49:22 +00:00
David Lord
a7f1f528f5
Merge pull request #920 from jdufresne/easy-install
Remove reference to deprecated easy_install; use pip instead
2018-11-19 20:06:17 -08:00
David Lord
194c9d4135
Merge pull request #926 from PinkFloyded/last_filter_doc_update
Clarify in docs that last filter doesn't work with generators
2018-11-19 20:04:17 -08:00
PinkFloyded
7b6dd16d71 Clarify that last filter doesn't work with generators 2018-11-17 05:03:46 +05:30
Jon Dufresne
d2ab8ac459 Remove reference to deprecated easy_install; use pip instead
easy_install is deprecated and its use is discouraged by PyPA:

https://setuptools.readthedocs.io/en/latest/easy_install.html

> Warning: Easy Install is deprecated. Do not use it. Instead use pip.

Follow upstream advice and only recommended supported tools. Replace
with pip.
2018-11-02 06:52:07 -07:00
David Lord
c89351fd45
Merge pull request #918 from TGogniashvili/tg.fix-lineno
parser: Fix typo `self.lineno` -> `token.lineno`
2018-10-30 06:52:36 -07:00
Tornike Gogniashvili
f98266115d parser: Fix typo self.lineno -> token.lineno 2018-10-29 19:32:49 +00:00
David Lord
11888dcd1a
Merge pull request #914 from greyli/fix-tag-statement-in-docs
[Docs] Fix ambiguity in include section
2018-10-18 05:24:28 -07:00
Grey Li
dd05562460
Fix ambiguity in include section 2018-10-18 12:59:19 +08:00
David Lord
7a6704db55
Merge pull request #797 from jdufresne/pyreq
Pass python_requires argument to setuptools
2018-08-30 07:09:27 -07:00
David Lord
f9bb207ff7
Merge pull request #891 from jdufresne/ws
Trim trailing white space throughout the project
2018-08-30 07:09:00 -07:00
David Lord
5ecdc80e16
Merge pull request #892 from jdufresne/trove-pypy
Add trove classifier for PyPy support
2018-08-30 07:08:16 -07:00
Jon Dufresne
33d6401e59 Add trove classifier for PyPy support
Tested during CI since 761da6ff61.
2018-08-29 21:03:24 -07:00
Jon Dufresne
148b6fb3c5 Trim trailing white space throughout the project
Many editors clean up trailing white space on save. By removing it all
in one go, it helps keep future diffs cleaner by avoiding spurious white
space changes on unrelated lines.
2018-08-29 20:58:03 -07:00
Jon Dufresne
ccac9402fc Pass python_requires argument to setuptools
Helps pip decide what version of the library to install.

https://packaging.python.org/tutorials/distributing-packages/#python-requires

> If your project only runs on certain Python versions, setting the
> python_requires argument to the appropriate PEP 440 version specifier
> string will prevent pip from installing the project on other Python
> versions.

https://setuptools.readthedocs.io/en/latest/setuptools.html#new-and-changed-setup-keywords

> python_requires
>
> A string corresponding to a version specifier (as defined in PEP 440)
> for the Python version, used to specify the Requires-Python defined in
> PEP 345.
2018-08-29 20:25:02 -07:00
David Lord
b9932a0e5b
Merge pull request #853 from doobeh/584-filters-index
Quick lookup table for builtin filters and tests-- references #584
2018-08-07 10:43:48 -07:00
David Lord
0273753a05
Merge pull request #869 from jwflory/docs/vim-syntax
Update integration docs for Vim syntax highlighting
2018-08-07 10:41:26 -07:00
David Lord
a7ba0b6378
Merge pull request #867 from The-Compiler/collections
Import abstract base classes from collections.abc
2018-08-07 10:29:46 -07:00
Florian Bruhin
31bf9b7e71
Import abstract base classes from collections.abc
In Python 3.7, importing ABCs directly from the `collections` module shows a
warning (and in Python 3.8 it will stop working) - see
c66f9f8d39

This fixes various DeprecationWarnings such as those:

```
.../jinja2/utils.py:485: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import MutableMapping

.../jinja2/runtime.py:318: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import Mapping
```
2018-08-07 10:25:51 -07:00
David Lord
0ece61041f
Merge pull request #883 from pallets/pytest
temporarily pin pytest to avoid test bug
2018-08-07 10:16:22 -07:00
David Lord
e2f0470fce
temporarily pin pytest to avoid test bug 2018-08-07 10:09:54 -07:00
David Lord
abf6089858
Merge pull request #868 from The-Compiler/py33
Drop Python 2.6 and 3.3 support
2018-08-07 09:53:28 -07:00
Florian Bruhin
86df058257 Add myself to AUTHORS 2018-06-27 22:02:45 +02:00
Florian Bruhin
5425921899 Also drop Python 2.6 2018-06-27 21:48:02 +02:00
Justin W. Flory
287c4ac8b2
Update integration docs for Vim syntax highlighting 2018-06-27 13:39:26 -05:00
Florian Bruhin
d1fb22fd45 Drop Python 3.3 support
It's currently broken on Travis (as it was dropped in 'wheel'), so continuing to
support it is probably not worth the pain.
2018-06-27 16:13:52 +02:00
Hsiaoming Yang
fb7e12cce6
Merge pull request #849 from funkyfuture/patch-1
Fixes 'awaitable' typo in api.rst
2018-05-15 16:52:11 +08:00
Anthony Plunkett
d28e9be7b3 Quick lookup table for builtin filters and tests-- references #584 2018-05-14 12:24:02 -04:00
David Lord
c7e22aeaba
Merge pull request #852 from ngr/html_highlight_fix
remove html+jinja highlight
2018-05-14 11:48:09 -04:00
David Lord
3482342842
Merge pull request #802 from abadger/allow-more-splatting
More closely match python splatting for calls
2018-05-14 11:21:27 -04:00
ngr
87672b85fc remove html+jinja highlight 2018-05-14 11:20:32 -04:00
David Lord
a1c5bcab0d
Merge pull request #851 from ngr/tests_for_raw
{% raw %} tests and note for documentation
2018-05-14 11:11:40 -04:00
ngr
0db3afced3 {% raw %} tests and note for documentation 2018-05-14 10:53:36 -04:00
Frank Sachsenheim
d0f8811d79
Fixes 'awaitable' typo in api.rst 2018-05-11 21:25:22 +02:00
David Lord
ff65310853
Merge pull request #841 from jdufresne/pypi
Update all pypi.python.org URLs to pypi.org
2018-04-18 19:40:50 -07:00
Jon Dufresne
453f81d84f Update all pypi.python.org URLs to pypi.org
For details on the new PyPI, see the blog post:

https://pythoninsider.blogspot.ca/2018/04/new-pypi-launched-legacy-pypi-shutting.html
2018-04-18 19:35:29 -07:00
David Lord
06b10ecb1d
Merge pull request #840 from nwalsh1995/master
Fix small typo in docs/api.rst
2018-04-17 16:51:24 -07:00
nwalsh1995
65337f8a78
Fix small typo 2018-04-17 14:55:13 -07:00
Armin Ronacher
e1e7735c76
Remove old GPL licensed emacs support
This is unmaintained anyways and we do not want to ship non BSD code.

Fixes #833
2018-03-28 23:31:03 +02:00
David Lord
3bb2ef8b83
Merge pull request #826 from terminalmage/issue823
Fix escaped characters in indent filter
2018-03-22 11:59:02 -07:00
Erik Johnson
a2f5e2c797
Remove unescape method for fixing concatenation issue
This ensures that we only concatenate Markup instances to other Markup
instances.
2018-03-19 21:56:54 -05:00
Erik Johnson
8ef99c3d6a
Add .pytest_cache/ to gitignore 2018-03-19 16:03:29 -05:00
Erik Johnson
5db859c5c3
Apply unesacpe fix when blank is True 2018-03-19 16:03:00 -05:00
Erik Johnson
50995cb7f9
Fix spelling in docstring 2018-03-19 14:30:46 -05:00
Erik Johnson
863558131c
Add test cases for quotes and expand coverage to include Markup input 2018-03-19 14:18:27 -05:00
Erik Johnson
e937c8a0de
Fix cases where filter input is not a Markup type
The previous commit assumes that the filter will always be a Markup
type, which is not correct.
2018-03-19 14:17:35 -05:00
Erik Johnson
bfdc8467d4
Fix escaped characters in indent filter
This unescapes after concatenating, to fix a bug introduced in Jinja
2.10 where lines concatenated contain escaped versions of non-ascii
characters.
2018-03-19 13:27:38 -05:00
Sean Sabbage
34b1ab9f6e Correct documentation for min method (#825) 2018-03-19 15:05:42 +01:00
David Lord
3d7cfc844b
Merge pull request #820 from jdufresne/typo
Fix typo: apparenlty -> apparently.
2018-03-05 06:23:40 -08:00
Jon Dufresne
a922a5f331 Fix typo: apparenlty -> apparently. 2018-03-04 12:15:52 -08:00
luzpaz
f2e9280f5e Fix typos (#815)
Found via `codespell -q 3` using v1.12.0.dev0
2018-02-18 15:57:01 +01:00
David Lord
041b7385c3
Merge pull request #806 from methane/lazy-async-patch
Lazy asyncsupport.patch_all()
2018-02-06 07:52:32 -08:00
David Lord
989a7db234
add changelog
fix unrelated docs issue
2018-02-06 07:48:10 -08:00
INADA Naoki
2c49d14cec Lazy asyncsupport.patch_all()
fixes #765
2018-02-06 21:52:57 +09:00
Godefroid Chapelle
c0c3b7879e Remove old statement about Python 3 (#803)
There is now Python 3 support...
2018-01-30 12:02:33 -08:00
Toshio Kuratomi
d6c016ba77 More closely match python splatting for calls
In Python, it's legal to use splats in function calls like this:

  call_function('123', *b, c=5, **d)

Prior to this change, jinja2 did not allow that. It mandated that all
splatting had to take place at the end of the call:

  call_function('123', c=5, *b, **d)

This commit allows both orders.

Additionally, this commit adds tests for more things that are illegal:
namely giving a function a positional argument after using a splat to
unpack positional arguments or giving a function a named argument after
using a double splat to unpack keyword arguments.
2018-01-29 15:44:46 -08:00
David Lord
96cd53d8ff
Merge pull request #799 from mkrizek/native-concat-list
Allow to pass a list to native_concat
2018-01-23 08:31:30 -08:00
David Lord
1f60059729
fix code block markup
closes #800
2018-01-18 08:56:55 -08:00
Martin Krizek
08a6faef2e Don't check for generator if not needed 2018-01-17 23:09:23 +01:00
Martin Krizek
9ef99dcd82 Allow to pass a list to native_concat 2018-01-17 21:38:58 +01:00
David Lord
fe3dadacdf
Merge pull request #787 from SabujXi/patch-1
Fix typo instanciable > instantiable
2017-12-01 10:27:13 -08:00
Md. Sabuj Sarker
78928bffab
Fix typo instanciable > instantiable 2017-12-02 00:10:39 +06:00
David Lord
9b255f4c36
Merge pull request #783 from luzpaz/trivial-typos
Trivial typos
2017-11-08 18:21:47 -07:00
Unknown
778ccb22e9 Trivial typos
Most non-user facing.
2017-11-08 20:02:28 -05:00
David Lord
b2dd36b60f
Bump version number to 2.11.dev 2017-11-08 12:02:36 -08:00
David Lord
78d2f67214
Bump version number to 2.10 2017-11-08 11:58:35 -08:00
David Lord
d9d3fc32f0
clean up MANIFEST.in
clean up make-release.py for py3
add rst extension to CHANGES for GitHub
clean up changelog formatting
2017-11-08 10:53:47 -08:00
ThiefMaster
072cdf97fa Support filters in set block
- e.g {% set foo | trim %}...{% endset %}
- closes #486
2017-10-31 23:04:45 +01:00
David Lord
d17c7dbbf0
Merge pull request #708 from jctanner/NATIVE_TYPES
Add support for the Environment to optionally return native types.
2017-10-31 12:16:10 -07:00
David Lord
6a7a263bc0
Merge branch 'master' into NATIVE_TYPES 2017-10-31 08:51:53 -07:00
Ricardo Lafuente
31f92b5947 Fix typo in docstring (#779) 2017-10-16 13:11:44 +02:00
David Lord
c3147611ec
codecov needs argparse on 2.6 2017-10-08 13:15:09 -07:00
Eli Boyarski
4750cf7c69 Minor docstring grammar fix (#772) 2017-09-18 16:24:38 +02:00
Adrian Moennich
fc5be479dd s/Add/Added/ in CHANGES
Pretty much all other entries also use past tense
2017-08-22 23:24:52 +02:00
Adrian Moennich
f3b6368e90 Merge branch '2.9-maintenance' 2017-08-22 23:17:15 +02:00
Adrian Moennich
cde2a54b87 Compile elif tag to elif instead of else: if
This avoids deep nesting in case of many `{% elif .. %}` blocks (which
would fail during execution) and also deep recursion (which may fail
during compilation)

fixes #759
2017-08-22 23:12:09 +02:00
Armin Ronacher
203540afcd Merge branch '2.9-maintenance' 2017-08-09 09:07:04 +02:00
Armin Ronacher
d117425f5e Added a changelog entry 2017-08-09 09:06:39 +02:00
Zac Medico
60a7e775d4 Fix regression in 2.9 involving unsafe Context.get_all() usage
Since commit d67f0fd4cc, callers
of Context.get_all() need to make a copy it they're going to
modify the result.

Fixes: d67f0fd4cc ("Generalize scoping.  This fixes #603")
2017-08-09 09:05:54 +02:00
James Tanner
68820c3976 quickly fix py3 tests 2017-07-25 22:11:22 -04:00
James Tanner
2ffeb693e3 Add requested patch for safe_repr and nodes.Impossible 2017-07-25 21:48:12 -04:00
Adrian
a5d9243462 Merge branch 'master' into NATIVE_TYPES 2017-07-14 17:19:17 +02:00
David Lord
5828b8ba4e Merge pull request #672 from alexk307/tests-memcached-bytecode-cache
Adds tests for the memcached bytecode cache module
2017-07-09 09:00:57 -07:00
David Lord
a675c85399
rewrite tests to match usage 2017-07-09 08:45:13 -07:00
Alex Kahan
6e74191f82
Adds tests for the memcached bytecode cache module 2017-07-09 08:45:05 -07:00
David Lord
711ad9dc21 Merge pull request #692 from dnmvisser/dictsort_reverse
Dictsort reverse
2017-07-08 09:10:33 -07:00
David Lord
34ca7f17c2
add test and changelog
use ignore_case function
2017-07-08 09:04:29 -07:00
Dick Visser
10fc8afc15
'reverse' option for dictsort 2017-07-08 08:54:34 -07:00
David Lord
07c0b875e5 Merge pull request #502 from berrange/callable
runtime: avoid assumption that all objects provide __call__
2017-07-07 14:00:44 -07:00
David Lord
e276843dae Merge pull request #685 from jkfran/master
Ignore empty lines in indent filter #681
2017-07-07 11:55:24 -07:00
David Lord
baa18e09a0
shorten arguments
add test for single line
update changelog
2017-07-07 11:46:19 -07:00
Francisco Jiménez Cabrera
bb8ef40957
Ignore empty lines in indent filter 2017-07-07 10:23:59 -07:00
David Lord
6f4d03c094 Merge pull request #617 from jackwilsdon/dont-skip-comma
Don't skip an erroneous comma when parsing "from"
2017-07-07 09:56:01 -07:00
David Lord
8f46becfff
add test and changelog 2017-07-07 09:51:31 -07:00
Jack Wilsdon
d26947c7f6
Don't skip an erroneous comma when parsing from
Currently we skip an extra comma when "with context" is not provided to
the "from" statement. This allows invalid code such as this:

  {% from "functions.html" import my_function,, %}

The primary issue with this is that it is not consistent when providing
"with context". The following code throws an error, contrary to the
previous example:

  {% from "functions.html" import my_function,, with context %}

It seems that the comma skipping was originally found in 0611e49 and was
accidentally put inside the "with context" check in ea847c5. It was then
updated to use "skip_if" in fdf9530.

There doesn't seem to be any reason for this check existing, as
double commas should never be allowed and serve no purpose in the
statement.
2017-07-07 09:42:16 -07:00
David Lord
a361b74fda Merge pull request #618 from jackwilsdon/stricter-from-parsing
Add stricter checking to "from ... import ..."
2017-07-07 09:40:35 -07:00
David Lord
32afe631c2
add tests and changelog 2017-07-07 09:34:32 -07:00
Jack Wilsdon
5d79372640
Add stricter checking to "from ... import ..."
Currently token parsing on "from ... import ..." is rather "loose" — it
sees the following "invalid" code as perfectly valid:

  {% from "functions" import my_function, %}
  {% from "functions" import, %}
  {% from "functions" import %}

This is caused by the parser ignoring non-name values where there should
be names, either as the first value or after commas.

This commit ensures only name values are allowed as the first value and
any values after commas in the import section.
2017-07-07 08:42:25 -07:00
David Lord
2c61df138a Merge pull request #740 from davidism/optimize-tests
Inline template tests during optimization
2017-07-07 08:20:34 -07:00
Sebastian Noack
c581d0ebe7
Inline template tests during optimization 2017-07-07 08:13:13 -07:00
James Tanner
40bc44c994
Add support for the Environment to optionally return native types.
This works by having an alternate CodeGenerator that avoids doing to_string
after the yield statement and a new version of concat that handles the returned
generator with a bit more "intelligence".
2017-07-06 14:26:09 -07:00
David Lord
ca1abd46bd Merge pull request #665 from pallets/operator-tests
Allow using comparison operator symbols as tests
2017-07-06 13:06:44 -07:00
David Lord
d62f0500a7
allow using comparison operator symbols as tests
add tests and aliases for all comparison operators
adjust docs to prefer short names for compare tests
closes #664
2017-07-06 12:59:28 -07:00
David Lord
05b55d516d Merge pull request #738 from davidism/test-config
Standard test config
2017-07-06 11:15:37 -07:00
David Lord
8261ac0fb7
standard test configuration
add branch coverage and codecov
2017-07-06 11:07:02 -07:00
David Lord
5ffbf8e571
fix docs warnings 2017-07-06 10:43:30 -07:00
David Lord
5477175dab
remove test copied from markupsafe 2017-07-06 10:41:46 -07:00
David Lord
3ff8ec7b82 Merge pull request #737 from davidism/minmax-filters
min and max filters
2017-07-06 08:48:07 -07:00
David Lord
52dcb4753a
parametrize tests
argument order consistent with existing filters
add changelog
2017-07-06 08:37:17 -07:00
Sebastian Noack
5435d35f97
Added min and max filters 2017-07-06 08:02:22 -07:00
David Lord
532171d3d2 Merge pull request #735 from davidism/unique-filter
Unique filter
2017-07-05 14:27:45 -07:00
David Lord
bda4e6b8df
make attrgetter take generic postprocess function
add changelog
2017-07-05 14:22:27 -07:00
David Lord
f2fc06d3ac
Merge branch 'master' into unique-filter 2017-07-05 11:58:34 -07:00
David Lord
ecba702fe3 Merge pull request #734 from davidism/dont-inline-random
Prevent random filter from being folded
2017-07-05 11:52:20 -07:00
David Lord
2e15e52adf
fix random test for py2
add changelog
2017-07-05 11:17:09 -07:00
David Lord
c8636fed17
test compares random filter to random call with same seed 2017-07-05 11:09:24 -07:00
David Lord
92c31d6a46
Merge branch 'master' into dont-inline-random 2017-07-05 10:11:00 -07:00
David Lord
47ef6a3baa Merge pull request #731 from pallets/feature/kill-stringdefs
Use str.isidentifier to match idents on python 3
2017-07-04 11:04:30 -07:00
David Lord
fb1e45315d
go back to generating regex, simplified
new version uses ~2KB vs 200KB memory, is ~100x faster to load
move script to generate pattern to scripts directory
add more tests
2017-07-04 10:00:32 -07:00
David Lord
1f1f031c2e
remove unnecessary \b from name regex 2017-07-03 09:40:07 -07:00
Adrian Moennich
e605ff1a0b Add support for {% trans trimmed ... %}
Same behavior as in Django: All linebreaks and the whitespace
surrounding linebreaks are replaced with a single space.

closes #504
2017-07-03 16:37:45 +02:00
David Lord
896aed2e3a
switch back to unicode escapes 2017-07-02 09:37:57 -07:00
David Lord
c8b37d4d1b
fix unicode for py2 2017-07-02 09:30:41 -07:00
David Lord
5de1f1b26b
only test master and maintenance branches
avoids duplicate work for internal prs
2017-07-02 09:19:02 -07:00
David Lord
c5d78bed5a
test for new identifier lexer
currently fails on special case unicode
2017-07-02 09:18:20 -07:00
Armin Ronacher
2177fc4aae Added missing identifiers to the name re 2017-07-02 00:30:25 +02:00
Armin Ronacher
d6a4a34f69 Inversed invalid logic 2017-07-01 23:29:23 +02:00
Armin Ronacher
f823bdb777 Use str.isidentifier to match idents on python 3 2017-07-01 20:41:24 +02:00
Adrian
c7dfa21a2b Merge pull request #684 from ThiefMaster/set-namespaces
Add namespace objects that support attribute assignment
2017-06-24 11:00:47 +02:00
Adrian Moennich
e0475f94fc Don't allow setting real attributes on ns objects
https://github.com/pallets/jinja/pull/684#issuecomment-291958060
2017-06-24 10:56:54 +02:00
Adrian Moennich
cc1d287b2b Add docs for namespace functionality 2017-06-24 10:56:54 +02:00
Adrian Moennich
e2a186998f Add unit tests for namespace functionality 2017-06-24 10:56:54 +02:00
Adrian Moennich
c2ee56db0e Add support for namespace attribute assignment 2017-06-24 10:56:54 +02:00
Adrian
b73cb489c5 Merge pull request #676 from ThiefMaster/loop-lookarounds
Add previtem/nextitem/changed() to loop context
2017-06-24 10:55:37 +02:00
Adrian Moennich
bc076b3e25 Add changed() to loop context 2017-06-24 10:52:06 +02:00
Adrian Moennich
9bdb547b0e Add previtem/nextitem to loop context
related: #641
2017-06-24 10:52:06 +02:00
Adrian Moennich
edac1a8d9f Add @ThiefMaster to list of contributors 2017-06-24 10:52:06 +02:00
David Lord
bec0065c4e Merge pull request #721 from jpassaro/issue_720
disable recursive comments in vim syntax file
2017-06-02 08:40:52 -07:00
John Passaro
f27d768130 disable recursive comments in vim syntax file
Fixes #720
2017-06-02 11:23:36 -04:00
David Lord
3f49ba22da Merge pull request #718 from ayalash/issue_709
Make tojson always safe (fix #709)
2017-05-23 14:58:02 -07:00
David Lord
86346976c6
add changelog
[ci skip]
2017-05-23 14:57:34 -07:00
Ayala Shachar
9f30bc8c4d
Make tojson always safe (fix #709) 2017-05-23 13:44:16 -07:00
David Lord
d905cf0b6c Merge pull request #703 from jdufresne/https
In documentation, prefer https over http when available
2017-04-09 15:57:56 -07:00
Jon Dufresne
3b1ddea8ac In documentation, prefer https over http when available 2017-04-09 15:21:05 -07:00
David Lord
34346bd7d7 Merge pull request #702 from jdufresne/rm-debug-print
Remove print() output during test
2017-04-09 14:33:16 -07:00
David Lord
e6a4db8241 Merge pull request #701 from jdufresne/trove-36
Add trove classifier for Python 3.6
2017-04-09 14:32:53 -07:00
Jon Dufresne
0f00f8ec79 Remove print() output during test
Looks like it was left in from debugging.
2017-04-09 14:29:17 -07:00
Jon Dufresne
27fffd4dcb Add trove classifier for Python 3.6 2017-04-09 14:24:33 -07:00
David Lord
43f86e4f6f Merge pull request #700 from brunodoamaral/patch-1
Fixed incorrect merge in setup.py
2017-04-05 07:26:07 -07:00
Bruno Guberfain do Amaral
ad2d90e78d Fixed incorrect merge in setup.py
I just don't know if the correct version is 2.9.7.dev or 2.10.dev
2017-04-05 11:01:25 -03:00
Armin Ronacher
044e40b7a7 Merge branch 'master' of github.com:pallets/jinja 2017-04-03 15:12:19 +02:00
Armin Ronacher
c1cd154278 Merge branch '2.9-maintenance' 2017-04-03 15:12:08 +02:00
Armin Ronacher
5b335b7a9e 2.9.7-dev 2017-04-03 15:11:44 +02:00
Armin Ronacher
d78a1b079c Bump version number to 2.9.6 2017-04-03 15:11:27 +02:00
Armin Ronacher
516f45b060 Updated release command 2017-04-03 15:11:09 +02:00
Armin Ronacher
faceeca784 Set release date 2017-04-03 15:08:43 +02:00
David Lord
d3ed6c7947 Merge pull request #693 from tedder/multiple_argument_select_documentation
add examples showing > 1 argument in filter
2017-03-17 14:23:18 -07:00
tedder
f80a3b1f21
add examples showing > 1 argument in filter
This is implied but poorly documented. A few examples make it clear.
2017-03-17 13:15:12 -07:00
Adrian Moennich
a8a9ec2f29 Fix custom contexts in fast resolve mode
closes #675
2017-03-15 19:19:04 +01:00
Daniel van Flymen
96f52e6a8f Fix typo (#687) 2017-03-01 20:10:34 +01:00
Adrian Moennich
b5eee90a82 Use proper versionadded annotation in docs 2017-02-26 18:01:59 +01:00
Jeff Widman
6c4249ee3b bdist_wheel replaces wheel
https://packaging.python.org/distributing/#universal-wheels
2017-02-10 23:12:14 -08:00
Mr. Senko
432daeac23 Return empty list when debug_info is empty string 2017-01-29 13:34:25 +02:00
Mr. Senko
a1588c6aae Add test for Template.get_corresponding_lineno()
this currently breaks with an exception inside Jinja
2017-01-29 13:29:00 +02:00
Armin Ronacher
921eb81d2e Merge branch '2.9-maintenance' 2017-01-28 15:44:17 +01:00
Armin Ronacher
b5d4599a74 2.9.6-dev 2017-01-28 15:43:46 +01:00
Armin Ronacher
09f8b2b2d1 Bump version number to 2.9.5 2017-01-28 15:42:29 +01:00
Armin Ronacher
d5e57f6749 Set date for 2.9.5 2017-01-28 15:42:19 +01:00
Armin Ronacher
2ed03c6d6b Merge branch '2.9-maintenance' 2017-01-28 15:34:25 +01:00
Armin Ronacher
add79164c4 Fixed async macro autoescape. Fixes #671 2017-01-28 15:33:09 +01:00
Armin Ronacher
059fbe5c00 Merge branch '2.9-maintenance' 2017-01-24 20:49:51 +01:00
Armin Ronacher
6295976154 Reduce unused unicodedata dump. Fixes #666 2017-01-24 20:49:43 +01:00
Armin Ronacher
04644ce004 Merge branch '2.9-maintenance' 2017-01-24 20:22:27 +01:00
Armin Ronacher
8df94bd344 Resolved extends errors in async mode (Fixes #668) 2017-01-24 20:22:19 +01:00
Armin Ronacher
d927c88750 Merge branch '2.9-maintenance' 2017-01-24 20:16:20 +01:00
Armin Ronacher
ca124c5cfe Correctly use buffer for else frame in loops. Fixes #669 2017-01-24 20:16:02 +01:00
Markus Unterwaditzer
0fcf45162d Merge branch '2.9-maintenance' 2017-01-24 16:36:16 +01:00
Andrew Arendt
c74de7282b fix failing tests: removed some broken code (#661) 2017-01-24 16:36:07 +01:00
Armin Ronacher
c8e7d98c63 Added changelog entry for #658 2017-01-12 23:50:08 +01:00
Dirk D
7ab79c62ef Add "is in" containment test (#658) 2017-01-12 13:03:38 -08:00
Armin Ronacher
5c9de9cf07 Merge branch 'master' of github.com:pallets/jinja 2017-01-12 20:11:22 +01:00
Armin Ronacher
05b0a7e434 Merge branch '2.9-maintenance' 2017-01-12 20:11:00 +01:00
Armin Ronacher
c6ddeb7d5f Add support back for custom resolves on old resolve method 2017-01-12 20:10:58 +01:00
Andrew Arendt
414c1d1e62 fix failing tests: removed some broken code (#661) 2017-01-12 10:46:04 -08:00
Armin Ronacher
222b3624de Merge branch '2.9-maintenance' 2017-01-12 16:00:17 +01:00
Armin Ronacher
9574abe564 Added a note for #657 2017-01-12 16:00:02 +01:00
Armin Ronacher
095663c734 Merge branch '2.9-maintenance' 2017-01-12 15:55:29 +01:00
Armin Ronacher
f30f5d8b4d Also restore original str method 2017-01-12 15:55:20 +01:00
Armin Ronacher
818ae6506a Merge branch '2.9-maintenance' 2017-01-12 15:53:36 +01:00
Armin Ronacher
785485114f Restore original tuple repr for grouper. Fixes #654 2017-01-12 15:53:12 +01:00
Armin Ronacher
220659b52d Merge branch '2.9-maintenance' 2017-01-12 15:47:26 +01:00
Armin Ronacher
78c9612299 Added a note on loop scoping 2017-01-12 15:47:18 +01:00
Armin Ronacher
ad5685f3cb Merge branch '2.9-maintenance' 2017-01-12 15:43:39 +01:00
Armin Ronacher
716cfb7537 Added another regression test for ansible/ansible#20063 2017-01-12 15:43:31 +01:00
Armin Ronacher
159fe78aef Merge branch '2.9-maintenance' 2017-01-12 15:38:38 +01:00
Armin Ronacher
3e9937cd95 Added a test for an assumed regression (refs #659) 2017-01-12 15:38:31 +01:00
Armin Ronacher
4e7fd1a521 Merge branch '2.9-maintenance' 2017-01-10 09:24:55 +01:00
Armin Ronacher
256ad51137 2.9.5-dev 2017-01-10 09:24:24 +01:00
Armin Ronacher
df8296af7e Bump version number to 2.9.4 2017-01-10 09:24:10 +01:00
Armin Ronacher
a79d596d1c 2.9.4 2017-01-10 09:23:55 +01:00
Armin Ronacher
1986933d58 Merge branch 'master' of github.com:pallets/jinja 2017-01-10 09:21:57 +01:00
Armin Ronacher
5a8e77151e Merge branch '2.9-maintenance' 2017-01-10 09:21:45 +01:00
Armin Ronacher
fb47dfac60 Allow to reconfigure the default for truncate leeway
Refs #610
2017-01-10 09:21:15 +01:00
Adrian
3e7ea671ab Improve issue template 2017-01-09 17:37:18 +01:00
Armin Ronacher
793ddd4ae9 Merge branch '2.9-maintenance' 2017-01-09 16:51:14 +01:00
Armin Ronacher
e73c574c21 Resolved bad code generation on toplevel ifs
This fixes #651
2017-01-09 16:50:55 +01:00
Armin Ronacher
9949832087 Merge branch '2.9-maintenance' 2017-01-09 12:23:32 +01:00
Armin Ronacher
ef718011e5 Correctly scope loop filters. Fixes #649 2017-01-09 12:23:18 +01:00
Armin Ronacher
b088619457 Merge branch '2.9-maintenance' 2017-01-09 11:05:46 +01:00
Armin Ronacher
a7d4ec51f2 Merge branch '2.9-maintenance' of github.com:pallets/jinja into 2.9-maintenance 2017-01-09 11:03:10 +01:00
Armin Ronacher
a9b9258203 Increment bytecode cache version. Fixes #650 2017-01-09 11:02:55 +01:00
Adrian
75894098e0 Show 2.9 build badge instead of 2.7 in README 2017-01-09 02:31:09 +01:00
Adrian Moennich
04b30cdd5c Remove unused/duplicate imports 2017-01-09 00:21:45 +01:00
Adrian Moennich
462b7868a2 Fix another invalid \s escale sequence 2017-01-09 00:08:40 +01:00
Adrian Moennich
76a8b5e85f Move regex flags to separate argument 2017-01-09 00:08:19 +01:00
Adrian Moennich
7ae752fc01 Enable py36 in tox.ini 2017-01-09 00:08:13 +01:00
Armin Ronacher
d66b81b73c Merge branch '2.9-maintenance' 2017-01-08 23:40:52 +01:00
Armin Ronacher
be16786d2d Fixed some string literal warnings. Fixes #646 2017-01-08 23:40:38 +01:00
Armin Ronacher
fd7969acd6 Merge branch '2.9-maintenance' 2017-01-08 22:25:11 +01:00
Armin Ronacher
b8bd94afda 2.9.4-dev 2017-01-08 22:24:32 +01:00
Armin Ronacher
c1b076e8e5 Bump version number to 2.9.3 2017-01-08 22:23:53 +01:00
Armin Ronacher
7a01d2967e 2.9.3 2017-01-08 22:23:25 +01:00
Armin Ronacher
7ec16c5176 Merge branch '2.9-maintenance' 2017-01-08 15:39:25 +01:00
Armin Ronacher
90ac7644d0 Implement with-tag with a custom node 2017-01-08 15:35:56 +01:00
Armin Ronacher
75bbd40730 Added test for the scope node 2017-01-08 14:38:00 +01:00
Armin Ronacher
16e4daebc4 Optimize the with test 2017-01-08 14:22:29 +01:00
Armin Ronacher
53e2572b5c Moved with test to coretags 2017-01-08 14:20:55 +01:00
Armin Ronacher
6173cf6fc2 Added support for unoptimized scopes 2017-01-08 12:01:27 +01:00
Armin Ronacher
75176bdbb5 WIP for overlay scopes 2017-01-08 11:22:01 +01:00
Armin Ronacher
95fb2bf51a Merge branch '2.9-maintenance' 2017-01-08 11:21:39 +01:00
Armin Ronacher
b1a56de18a Support new scoping rules in scoped blocks 2017-01-08 11:21:32 +01:00
Armin Ronacher
62d72eea41 Merge branch '2.9-maintenance' 2017-01-08 09:43:57 +01:00
Armin Ronacher
31e002499c Mention new set scoping behavior. Refs #641 2017-01-08 09:43:47 +01:00
Armin Ronacher
53e3c9593d Moved a changelog entry to the right release 2017-01-08 09:41:34 +01:00
Armin Ronacher
6b8a14a510 Merge branch '2.9-maintenance' 2017-01-08 09:28:06 +01:00
Armin Ronacher
07c33a5a3c Added bug reference 2017-01-08 09:27:51 +01:00
Armin Ronacher
6f7fa5cdcd Do not use yield from for blocks with buffers. Fixes #645 2017-01-08 09:27:11 +01:00
Armin Ronacher
c1b44690ba Merge branch '2.9-maintenance' 2017-01-08 03:19:04 +01:00
Armin Ronacher
8172db059d Implement consistent scoping for sets in loops
While technically this applies to any scope and not just for loops
it comes up most commonly in the context of for loops.  This now
defines the behavior for scoping in a way that is consistent but
different than it was in the past.  There is an ongoing conversation
if we should keep it that way or not.

References #641
2017-01-08 03:17:30 +01:00
Armin Ronacher
1e1173745b Merge branch '2.9-maintenance' 2017-01-08 02:51:29 +01:00
Armin Ronacher
b557eca315 2.9.3-dev 2017-01-08 02:50:57 +01:00
Armin Ronacher
3a0f01df84 Bump version number to 2.9.2 2017-01-08 02:50:41 +01:00
Armin Ronacher
8a04e16325 2.8.2 2017-01-08 02:50:27 +01:00
Armin Ronacher
7064298b53 Merge branch '2.9-maintenance' 2017-01-08 02:19:12 +01:00
Armin Ronacher
6235644d33 Add support for explicit callers
This adds support for a never intended Jinja2 feature which however
worked in limited support before due to a bug with the identifier
scoping.  A quick github code search indicates that developers
commonly did this to set the default caller to none.

This fixes #642
2017-01-08 02:16:41 +01:00
Armin Ronacher
a8df1f7392 Merge branch '2.9-maintenance' 2017-01-07 23:23:07 +01:00
Armin Ronacher
e3022523a5 Correct bad scoping for for loops. This fixes #640 2017-01-07 23:15:07 +01:00
Armin Ronacher
7685ea59db Merge branch '2.9-maintenance' 2017-01-07 16:57:25 +01:00
Armin Ronacher
8ce8fd39de 2.9.2-dev 2017-01-07 16:56:57 +01:00
Armin Ronacher
8a6f084852 Bump version number to 2.9.1 2017-01-07 16:56:20 +01:00
Armin Ronacher
bf7b924d4a Added changelog for 2.9.1 2017-01-07 16:56:13 +01:00
Armin Ronacher
2c74f2468b Resolved a regression in 2.9 with macro call scoping 2017-01-07 16:54:57 +01:00
Armin Ronacher
352334c566 2.10-dev 2017-01-07 16:36:03 +01:00
Armin Ronacher
3e4ebc80f8 Bump version number to 2.9 2017-01-07 16:35:43 +01:00
Armin Ronacher
44aec52cad Set release date 2017-01-07 16:35:37 +01:00
Armin Ronacher
bbe0a4174c Bump up the copyright to 2017 2017-01-07 16:17:14 +01:00
Armin Ronacher
b81a8a3e37 Updated docs on autoescaping and made select_autoescape case insensitive 2017-01-07 16:13:39 +01:00
Armin Ronacher
0020a477db Added a more convenient autoescaping function 2017-01-07 16:07:50 +01:00
Armin Ronacher
a27a503cea Move the autoescape extension and with statement to be built-in 2017-01-07 15:55:20 +01:00
Armin Ronacher
d67f0fd4cc Generalize scoping. This fixes #603 2017-01-07 15:35:50 +01:00
Armin Ronacher
147bd571ad Change grouping behavior of tests. This fixes #401 2017-01-07 15:15:06 +01:00
Armin Ronacher
028f058370 Add a policy for the ascii literal behavior. Fixes #392 2017-01-07 14:57:44 +01:00
Armin Ronacher
fa80a0df1f Optimize parameter lookup by default 2017-01-07 14:32:32 +01:00
Armin Ronacher
01d9e7e906 Smaller fixes to stuff that broke on 3.x 2017-01-07 02:44:37 +01:00
Armin Ronacher
e8ef8aacee Kill const folding for call which does not work anyways 2017-01-06 23:54:19 +01:00
Armin Ronacher
fa2d955542 Fix various optimizer bugs. This fixes #548 2017-01-06 23:08:00 +01:00
Armin Ronacher
894ddb1b36 Added a test for macro scoping in loops 2017-01-06 21:48:53 +01:00
Armin Ronacher
6a754cb83a Block sets are now safe. This fixes #490 2017-01-06 21:42:55 +01:00
Armin Ronacher
e273b3af24 Add note on HTML usage of tojson filter 2017-01-06 21:35:46 +01:00
Armin Ronacher
e71a130607 Ported tojson filter. Fixes #458 2017-01-06 21:33:51 +01:00
Armin Ronacher
ffe0caa1f0 Expect format 2017-01-06 21:01:47 +01:00
Armin Ronacher
73e2b51052 Cleaned up shitty syntax in testsuite 2017-01-06 21:00:01 +01:00
Armin Ronacher
cb4b551e12 Fixed self references in macros 2017-01-06 20:57:30 +01:00
Armin Ronacher
3cb7d8a452 Turns out order tracking for loads is not useful 2017-01-06 16:45:48 +01:00
Armin Ronacher
960228892b Write loads in order they were defined 2017-01-06 16:40:41 +01:00
Armin Ronacher
341635252a Killed some whitespace 2017-01-06 15:47:31 +01:00
Armin Ronacher
85b4e3d550 Optimize the case where we know about defined variables 2017-01-06 14:48:48 +01:00
Armin Ronacher
b9655a457d Set macro autoescape behavior at call instead of compile time. Fixes #565 2017-01-06 14:29:38 +01:00
Zach Malone
b3c174b31a Fix and/or logic in docs (#521) 2017-01-06 14:19:41 +01:00
Armin Ronacher
e7e3752c39 Added changelog entry 2017-01-06 13:09:25 +01:00
Armin Ronacher
49c382a1d0 Merge pull request #610 from jab/jab-do_truncate
Fix and improve do_truncate
2017-01-06 13:08:57 +01:00
Armin Ronacher
5453db1711 Ensure we depend on recent markupsafe. Fixes #638 2017-01-06 13:00:34 +01:00
Armin Ronacher
6eca1aefdd Added a missing test 2017-01-06 13:00:19 +01:00
Armin Ronacher
2ce56dd4f4 Merge branch 'feature/no-locals' 2017-01-06 12:53:39 +01:00
Armin Ronacher
d1a32e7502 Better error messages for some undefines. This fixes #575 2017-01-06 12:53:31 +01:00
Armin Ronacher
a4dde4b065 Optimize emitting of forced yields 2017-01-06 00:02:56 +01:00
Armin Ronacher
e5e3e61242 Support yield from if we can use it 2017-01-05 23:48:18 +01:00
Armin Ronacher
46025fb3c7 Do not emit make_logging_undefined to runtime 2017-01-05 23:33:27 +01:00
Major Hayden
65fbf324ab Add test for greater/less than (#624)
It can be helpful to have a test for values that are greater or less than
another value, especially when looping over lists and using `select()` or
`selectattr()` filters. This patch adds tests that allow a developer to
check if a value is greater or less than another value.

For example, if I have a list of vehicles and I want to find the motorcycles:

    vehicles | selectattr('wheels', 'lessthan', 3)

Or, if I want to find large trucks:

    vehicles | selectattr('wheels', 'greaterthan', 4)

Tests are included.
2017-01-04 08:21:53 -08:00
Armin Ronacher
9b2a4f49c6 Changed behavior of macro defaults to be frame bound 2017-01-03 23:45:30 +01:00
Armin Ronacher
5ab69f24f9 Checked in a failing test 2017-01-03 23:45:30 +01:00
Armin Ronacher
0fc73b16c0 Added a second test for #278 2017-01-03 23:45:30 +01:00
Armin Ronacher
711523d6c5 Added a test for #278 2017-01-03 23:45:30 +01:00
Armin Ronacher
994e1f3632 Added test for #86 2017-01-03 23:45:30 +01:00
Armin Ronacher
96ed5c0dda Alias resolve and undefined 2017-01-03 23:45:30 +01:00
Armin Ronacher
5700025858 Kill stray print 2017-01-03 23:45:30 +01:00
Armin Ronacher
bb0dc86a9e Small optimizations for escape branches 2017-01-03 23:45:30 +01:00
Armin Ronacher
05ad245d5e Small optimization for recursive loops 2017-01-03 23:45:30 +01:00
Armin Ronacher
258eae66c5 Use a separate scope for the loop else branch 2017-01-03 23:45:30 +01:00
Armin Ronacher
3f4eb21234 Clarified for else todo 2017-01-03 23:45:29 +01:00
Armin Ronacher
8d06cfb64e Small optimization for python scopes 2017-01-03 23:45:29 +01:00
Armin Ronacher
3d7f099688 Fixed a typo 2017-01-03 23:45:29 +01:00
Armin Ronacher
06895a3eb0 Cleaned up some code that no longer needs to exist 2017-01-03 23:45:29 +01:00
Armin Ronacher
e6aea1bf33 Stop assigning stuff to the frame that does not belong there 2017-01-03 23:45:29 +01:00
Armin Ronacher
c109906c08 Kill now unused assigned_names 2017-01-03 23:45:29 +01:00
Armin Ronacher
22bb00b275 Kill some dead code 2017-01-03 23:45:29 +01:00
Armin Ronacher
05fea281d8 Force missing to be a local 2017-01-03 23:45:29 +01:00
Armin Ronacher
76edefaf35 Fixed from imports with context 2017-01-03 23:45:29 +01:00
Armin Ronacher
f81af92c2f Make tests pass on 3.x again 2017-01-03 23:45:29 +01:00
Armin Ronacher
ff8e2e55e2 Made all tests pass again 2017-01-03 23:45:29 +01:00
Armin Ronacher
7ab5ed50d4 Fixed some broken tests 2017-01-03 23:45:29 +01:00
Armin Ronacher
058bc8a98d Fixed various breakage from the new id tracking 2017-01-03 23:45:29 +01:00
Armin Ronacher
bd32b37dd3 Changed behavior of local extraction 2017-01-03 23:45:29 +01:00
Armin Ronacher
4a72be8aff Reset variables for scoping 2017-01-03 23:45:29 +01:00
Armin Ronacher
9cd8d8e3b0 Fixed debug support locals for new behavior 2017-01-03 23:45:29 +01:00
Armin Ronacher
1205e641ed First pass on integrating id tracking 2017-01-03 23:45:29 +01:00
Armin Ronacher
b5d99210f1 Added new-style id tracking code 2017-01-03 23:45:29 +01:00
Armin Ronacher
ebed13eb2b Changelog and __rsub__ handling 2017-01-03 19:33:25 +01:00
Armin Ronacher
479d870eba Merge pull request #530 from nick-garcia/master
Subtraction from Undefined does not raise UndefinedError
2017-01-03 19:31:01 +01:00
Armin Ronacher
61dc8d020a Changelog entry 2017-01-03 19:19:29 +01:00
Armin Ronacher
2cacbac15a Merge pull request #525 from iffy/fix-cycle-next
Give Cycler a next() method so that it works in python2 and 3
2017-01-03 19:18:42 +01:00
Armin Ronacher
45b59b522a Support block-set in toplevel situations when extends is used 2016-12-31 01:11:20 +01:00
Armin Ronacher
0ea221f53b Support old-style classes for attribute lookups. Fixes #631 2016-12-31 00:47:15 +01:00
Armin Ronacher
e253520d96 Added docs for policies 2016-12-31 00:43:50 +01:00
Armin Ronacher
47b55f8843 Make noopener the default for urlize 2016-12-31 00:40:38 +01:00
Armin Ronacher
4a70e7a63e Merge branch 'master' of github.com:pallets/jinja 2016-12-29 22:54:50 +01:00
Armin Ronacher
73351f3216 Merge branch '2.8-maintenance' 2016-12-29 16:01:54 +01:00
Armin Ronacher
74bd64e563 Fixed a name error for an uncommon attribute access in the sandbox 2016-12-29 16:01:35 +01:00
Armin Ronacher
ba8be08ab2 Merge pull request #636 from hroncok/tests_rename
Rename tests to avoid name collision
2016-12-29 14:41:31 +01:00
Miro Hrončok
ba7cba0a4e Rename tests to avoid name collision
Previously, two tests where not executed because of name collision
2016-12-29 14:28:38 +01:00
Armin Ronacher
3097b97ef3 Merge branch '2.8-maintenance' 2016-12-29 14:17:42 +01:00
Armin Ronacher
d3b456fea3 2.8.2.dev0 just in case 2016-12-29 14:17:12 +01:00
Armin Ronacher
209fd39b27 Bump version number to 2.8.1 2016-12-29 14:16:16 +01:00
Armin Ronacher
a010f5fd33 Merge branch '2.8-maintenance' of github.com:pallets/jinja into 2.8-maintenance 2016-12-29 14:15:27 +01:00
Armin Ronacher
002edca796 Updated changelog 2016-12-29 14:14:44 +01:00
Armin Ronacher
9b53045c34 SECURITY: support sandboxing in format expressions 2016-12-29 14:13:38 +01:00
Armin Ronacher
a6e48b4263 Make slice work with async generators 2016-12-29 11:38:43 +01:00
Armin Ronacher
2b03052c9b Also test on 3.6 2016-12-29 00:23:37 +01:00
Armin Ronacher
9ab3113422 Added changelog entry 2016-12-29 00:22:56 +01:00
Armin Ronacher
8c734f1b69 Improved tests for sum 2016-12-29 00:22:11 +01:00
Armin Ronacher
8e08a21d1d ported list and sum 2016-12-29 00:20:34 +01:00
Armin Ronacher
af74d2df62 Improved tests for select 2016-12-29 00:20:17 +01:00
Armin Ronacher
f7bb60af00 Ported map and select 2016-12-29 00:11:40 +01:00
Armin Ronacher
5a8bc3194c Test sync and async generator 2016-12-29 00:06:09 +01:00
Armin Ronacher
043c954c26 Added reject/rejectattr with basic async support 2016-12-29 00:05:02 +01:00
Armin Ronacher
1df67cf172 Made join filter work with async 2016-12-28 23:49:33 +01:00
Armin Ronacher
7641542980 Restructured tests for async filters 2016-12-28 23:44:36 +01:00
Armin Ronacher
7c62100321 Made groupby work with async 2016-12-28 23:39:03 +01:00
Armin Ronacher
f071dff252 Improved internal async filter framework 2016-12-28 23:27:58 +01:00
Armin Ronacher
a25669db88 Added note for async from filter calls 2016-12-28 23:19:35 +01:00
Armin Ronacher
6445ec0861 First pass on async support for filters 2016-12-28 23:18:51 +01:00
Armin Ronacher
2fd008a796 Made the env._async property public for filters 2016-12-28 22:51:56 +01:00
Armin Ronacher
d8326d943e Started doc work for async 2016-12-28 22:51:46 +01:00
Armin Ronacher
7265e6f9f3 Make tests pass on older python versions again 2016-12-28 21:54:33 +01:00
Armin Ronacher
acab87a436 Support the same set of loop functions for async mode 2016-12-28 21:49:00 +01:00
Armin Ronacher
efa5d3161d Improved wrapper code so that the API is more consistent on failure 2016-12-28 20:31:14 +01:00
Armin Ronacher
48baa10f1e Fixed error message 2016-12-28 20:23:49 +01:00
Armin Ronacher
d4e14fc4d2 Added support for async loop context 2016-12-28 20:06:34 +01:00
Armin Ronacher
aa188fd860 Added basic support for async iter 2016-12-28 17:08:21 +01:00
Armin Ronacher
3e6992f271 Wrap generate to support async mode 2016-12-28 16:11:09 +01:00
Armin Ronacher
1c9ebf16e5 Auto skip async tests for imports 2016-12-28 16:08:07 +01:00
Armin Ronacher
63d732440b Added tests for async functionality with imports and includes 2016-12-28 15:55:54 +01:00
Armin Ronacher
f61ffbfb80 Added untested support for imports and includes in async mode 2016-12-28 15:33:14 +01:00
Armin Ronacher
1259162c99 Use more _get_default_module calls 2016-12-28 15:19:32 +01:00
Armin Ronacher
95d495aee5 First pass on implementing async default module 2016-12-28 15:17:10 +01:00
Armin Ronacher
55e2c4a01c Switch to short traceback 2016-12-28 15:15:10 +01:00
Armin Ronacher
42079ad35a Rewrap 2016-12-28 15:04:17 +01:00
Armin Ronacher
5be172a5e0 Stop use of .module in generated code 2016-12-28 14:57:34 +01:00
Armin Ronacher
7c90534875 Restore original render func for non async usage 2016-12-28 14:38:58 +01:00
Armin Ronacher
2b4d44b9b5 Basic async support for blocks 2016-12-28 14:37:56 +01:00
Armin Ronacher
21ad817c40 Updated setup.cfg for pytest 2016-12-28 13:34:04 +01:00
Armin Ronacher
62989728cd Improved async test 2016-12-28 13:33:37 +01:00
Armin Ronacher
9853794a6b Added test for macro async support 2016-12-28 13:32:42 +01:00
Armin Ronacher
d1b8f08470 Automatically await on function calls if necessary 2016-12-28 13:18:20 +01:00
Armin Ronacher
b11056d780 Initial support for async rendering 2016-12-28 12:40:42 +01:00
Armin Ronacher
e908a584fa Add async flags 2016-12-28 10:42:47 +01:00
Armin Ronacher
4fa37123b9 Fixed long standing wrong operator precedence 2016-12-28 10:07:52 +01:00
Armin Ronacher
a78bee7403 Updated gitignore to include venvs 2016-12-28 09:51:24 +01:00
Armin Ronacher
17f73a8701 Added a test for generator_stop 2016-12-28 09:51:01 +01:00
Armin Ronacher
61f39a9cd4 Restrict where we collect tests 2016-12-27 20:04:04 +01:00
Armin Ronacher
67d015e896 Merge branch 'master' of github.com:mitsuhiko/jinja2 2016-12-27 19:53:39 +01:00
Armin Ronacher
e7e14cf349 Added support for generator_stop 2016-12-27 19:52:43 +01:00
jfinkels
b42f535404 Uses re.compile flags argument, not inline flags (#628)
This commit replaces the use of terminal inline flags in a regular
expression in `re.compile`,

    re.compile(r'\w+(?u)')

with arguments to the `re.compile` function itself,

    re.compile(r'\w+', re.UNICODE)

because the former is deprecated as of Python 3.6.
2016-12-25 15:10:33 -08:00
Andrew Arendt
363ab44a48 Fix typos in CHANGES (#626) 2016-12-14 02:10:30 +01:00
Philippe Ombredanne
2e422481e9 Add license_file to setup.cfg metadata (#609)
Without this, the LICENSE file is never included in the built wheels: this makes it harder for users to comply with the license.
With this addition a file LICENSE.txt will be created in the `xxx.dist-info` directory with the content of the `license_file` file, e.g. the top level LICENSE.
2016-11-01 13:18:45 -07:00
jab
9f9606bc93 Fix and improve do_truncate
- Ensure that the requested max length be at least as long as the
  requested `end` value (e.g. 3 in the case of '...'). Fixes #539
- Add `leeway` parameter so that strings that just barely miss the
  requested max length cutoff can still be spared from unwanted truncation.
  Default value is 5.
- No longer append a space before appending `end` under any circumstances.
  Adding whitespace before ellipsis punctuation in English is grammatically
  incorrect.
2016-09-24 17:25:31 -04:00
Marcelo Jorge Vieira
390c3cec2b Fix typo in clear_caches docstring 2016-09-09 16:14:18 +02:00
Marcelo Jorge Vieira
312cf9a1a1 Fixed typo in jinja2/loaders.py (#606)
Replaced 'fileame' with 'filename'
2016-09-02 13:50:42 -07:00
Francisco Jiménez Cabrera
cfaec3382d Added a GitHub issue template (#599) 2016-07-19 14:58:17 -07:00
Jochen Kupperschmidt
8a49e066af Clarified and extended the docs for the {select|reject}[attr] filters. (#231) 2016-05-30 07:48:11 -07:00
Jeff Widman
760ce60dcc Merge pull request #585 from pgjones/master
Change environment cache key construction
2016-05-23 15:29:27 -07:00
pgjones
1a61008d61 Change environment cache key construction
Changing from a tuple of the loader ID and template name to a weakref
to the loader and the template name should avoid situations whereby
the loader has changed, yet the cached templates are returned. This
would occur if the id of the new loader matches the old. A weakref is
preferred over a direct reference so that the loader can be garbaged
collected.
2016-05-21 16:21:22 +01:00
Markus Unterwaditzer
042dadda53 Merge branch 'pgjones-master' 2016-05-19 20:59:56 +02:00
Markus Unterwaditzer
84e87127b4 Changelog for #583 2016-05-19 20:59:37 +02:00
pgjones
7d8ec0f3e8 Change cache key definitiion in environment
In 6671b973e6 the load_template method
was altered to use a cache key other than the template name. The key
chosen was the abs path as returned from the loader get_source
method. Unless there is no path in which case the name is
used. Unfortunately this introduced a performance regression, #485, as
the get_source method (in the FileStoreLoader) loads the template
(causing IO).

The purpose of #332 was to allow the loader to change whilst ensuring
the correct template was loaded, i.e. to fix this case

    env.loader = loader1
    env.get_template('index.html') # return loader1/index.html
    env.loader = loader2
    env.get_template('index.html') # also return loader1/index.html because of cache

This commit changes the cache key to be a tuple of the id(loader) and
the template name. Therefore fixing the above case without calling the
get_source method and thereby avoiding the IO load.

A test has been added to ensure the above case works as expected, this
required a minor refactor of the caching tests.
2016-05-19 19:42:16 +01:00
Adam Chainz
b927c9f271 README - fixes (#578)
* Add syntax highlighting
* Fix build table which doesn't display on Github RST renderer
2016-05-03 06:13:45 -07:00
David Lord
d9b879d1f9 use double ticks for code in rst 2016-05-02 07:35:44 -07:00
Jeff Widman
bd50d125c2 Merge pull request #577 from boidolr/documentation_fixes
Small documentation fixes
2016-05-01 23:43:25 -07:00
Raphael Boidol
e064e0e895 Remove sudo command from documentation (fixes #543).
Installations should be in a virtualenv.
2016-05-01 14:13:40 +02:00
Raphael Boidol
f9601c91bb Use constant name in doc (fixes #544) 2016-05-01 14:11:26 +02:00
Sebastian Noack
ec8452f6db Merge pull request #570 from mr-m/patch-1
Fix the typo in templates.rst
2016-04-19 15:53:47 +02:00
Dmitriy Trifonov
dec12639ca Fix the typo 2016-04-19 17:29:22 +06:00
Jeff Widman
6d2d3b88e1 Suggest installing via Pip (#569) 2016-04-15 07:10:13 -07:00
Jeff Widman
f409223901 Merge pull request #439 from jgmize/title-filter-capitalize-inside-parens
Make title filter capitalize words inside parens and other brackets
2016-04-15 00:49:40 -07:00
Jeff Widman
4de148709f Merge pull request #473 from snoack/redundant-sorting
Got rid of redundant sorting in groupby filter
2016-04-15 00:00:28 -07:00
Jeff Widman
080a5de275 Merge pull request #470 from snoack/partial-next
Use partial(next, ...) instead get_next()
2016-04-14 23:57:48 -07:00
Jeff Widman
f94ab4d548 Merge pull request #567 from gpanther/update-gae-example-in-faq
Update GAE example code
2016-04-14 23:54:42 -07:00
Attila-Mihaly Balazs
e2eab553f4 Update GAE example code
Update the Google App Engine example code to be compatible with the latest google app engine devserver.
2016-04-14 15:56:34 +03:00
Jeff Widman
39bfd792e9 Merge pull request #500 from snoack/setup-py-versions
Added Python 3.4 and 3.5 to the classifiers in setup.py
2016-04-12 23:01:03 -07:00
Markus Unterwaditzer
9837970fa8 Merge branch '2.8-maintenance' 2016-04-12 21:44:39 +02:00
Markus Unterwaditzer
368e1b117e Changelog for #466 2016-04-12 21:44:34 +02:00
Markus Unterwaditzer
89d05accf9 Merge branch 'snoack-issue-466' into 2.8-maintenance
Fix #467
Fix #466
2016-04-12 21:43:27 +02:00
Sebastian Noack
d4f0dd9032 Fixed int() filter for non-string objects #466 2016-04-12 21:43:16 +02:00
David Lord
d760b78a2f standard tox/travis config
fix pytest warning, don't prefix non-testcase classes with Test
2016-04-11 16:18:24 -07:00
Kojo Idrissa
d48cb2129c Fixed typo/grammar error (#532) 2016-04-10 12:04:46 -07:00
Adrian
f40da1bb99 Use container-based travis infrastructure (#496) 2016-04-10 09:05:38 -07:00
Guillaume Paumier
345e0ba5d6 Fix typo (#531) 2016-04-10 08:58:06 -07:00
Abdullah
99a78e0a0f link fix (#527) 2016-04-10 08:57:09 -07:00
Tim Swast
935d330b68 Change links for Babel to new docs location. (#562) 2016-04-10 08:48:09 -07:00
Sambhav Satija
75685ec5e5 Escape target attribute in the urlize function in utils.py. (#507) 2016-04-10 08:40:38 -07:00
José Carlos García
c5a860c741 change from @mitsuhiko to pallets project 2016-04-03 16:21:39 -07:00
Nick Garcia
dd85761ced Setting __sub__ equal to _fail_with_undefined_error so subtractions with
undefined variables will fail properly like other arithemtic operations.
2016-01-07 15:23:26 -08:00
Armin Ronacher
5b498453b5 Merge pull request #526 from ioab/master
docs: Integration link fix
2016-01-04 18:15:43 +01:00
Abdullah
678b4887e4 docs: Integration link fix 2016-01-04 20:13:07 +03:00
Armin Ronacher
9e72f38702 Merge pull request #523 from alimony/patch-1
Fix typo.
2016-01-04 18:08:36 +01:00
Matt Haggard
77781b93a5 Give Cycler a next() method so that it works in python2 and 3 2015-12-29 16:12:39 -07:00
Markus Amalthea Magnuson
c51e3ab6aa Fix typo. 2015-12-28 17:17:22 +01:00
Armin Ronacher
b78f2617b0 Merge branch '2.8-maintenance' 2015-11-20 10:05:39 +01:00
Armin Ronacher
8189d2164d Fixed for_qs for urlencode. This fixes #515 2015-11-20 10:05:12 +01:00
Armin Ronacher
f51862d6ca This is 2.8.1-dev 2015-11-20 10:04:20 +01:00
Armin Ronacher
6f7e161c68 Merge pull request #513 from spookylukey/patch-1
Fixed a few spelling mistakes in a docstring
2015-11-14 10:48:20 +01:00
Luke Plant
217e453a68 Fixed a few spelling mistakes in a docstring 2015-11-14 09:46:08 +00:00
Daniel P. Berrange
91255f86f6 runtime: avoid assumption that all objects provide __call__
Objects which are backed by native extensions do not provide
a __call__ attribute, but are none the less callable if the
native extension provides a 'tp_call' implementation.

The jinja2.runtime.Context.call method unconditionally
access the '__call__' attribute causing an exception to be
raised if the object was a native extension method.

A demo of the problem can be seen using PyGObject:

  $ cat demo.py
  #!/usr/bin/python

  from gi.repository import Gio
  from jinja2 import Environment

  f = Gio.File.new_for_path("/some/file.txt")
  print f.get_uri()

  t = Environment().from_string("""{{f.get_uri()}}""")
  print t.render(f=f)

Which when run results in

 $ ./demo.py
 file:///some/file.txt
 Traceback (most recent call last):
   File "./demo.py", line 10, in <module>
     print t.render(f=f)
   File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 969, in render
     return self.environment.handle_exception(exc_info, True)
   File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
     reraise(exc_type, exc_value, tb)
   File "<template>", line 1, in top-level template code
     AttributeError: 'gi.FunctionInfo' object has no attribute '__call__'

After this patch it produces

 $ ./demo.py
 file:///some/file.txt
 file:///some/file.txt

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-10-13 16:52:07 +01:00
Sebastian Noack
6c54ccddd0 Added Python 3.4 and 3.5 to the classifiers in setup.py 2015-10-06 16:14:28 +02:00
Markus Unterwaditzer
9b4b20aa56 Merge pull request #497 from snoack/pypy
Added pypy to the list of Python versions tested by Travis CI
2015-09-20 20:37:37 +02:00
Sebastian Noack
761da6ff61 Added pypy to the list of Python versions tested by Travis CI 2015-09-20 20:29:34 +02:00
Markus Unterwaditzer
97dcfa06b7 Don't pin to .0 version 2015-09-20 19:43:09 +02:00
Markus Unterwaditzer
64da40879c Merge pull request #495 from snoack/py35
Added Python 3.5 to tox and Travis configuration
2015-09-20 19:42:30 +02:00
Sebastian Noack
8920fd74b8 Added Python 3.5 to tox and Travis configuration 2015-09-20 19:26:05 +02:00
Sebastian Noack
c00226160e Use partial(next, ...) instead get_next() 2015-08-10 12:51:33 +02:00
Sebastian Noack
4975ca0362 Added unique filter 2015-08-10 12:25:21 +02:00
Sebastian Noack
9c7a2400a8 Prevent random filter from being inlined 2015-08-10 10:34:13 +02:00
Sebastian Noack
6d356f1bc3 Got rid of redundant sorting in groupby filter 2015-08-07 11:51:37 +02:00
Markus Unterwaditzer
50c6cd7f39 Merge pull request #472 from pydanny/pydanny-update-django-switch-docs
Remove conditions segment of Django section
2015-08-06 18:02:36 +02:00
Daniel Greenfeld
ff4ffde8b3 Removed outdated condition section on Django 2015-08-06 08:35:51 -07:00
Markus Unterwaditzer
57c288c9ba Merge pull request #471 from snoack/metaclass-improvement
Improve with_metaclass()
2015-08-06 09:12:34 +02:00
Sebastian Noack
743598d788 Improve with_metaclass() 2015-08-05 12:53:07 +02:00
Armin Ronacher
6bf78bcef8 Improve release script to support new format and wheels. 2015-07-26 19:51:10 +02:00
Armin Ronacher
56e187c3bb This is 2.9.dev 2015-07-26 19:50:27 +02:00
Armin Ronacher
966e1a409f Bump version number to 2.8 2015-07-26 19:49:40 +02:00
Armin Ronacher
75a9ddd193 Hardcode version in setup.py again. 2015-07-26 19:49:32 +02:00
Armin Ronacher
4083d96160 Release date is today. 2015-07-26 19:48:17 +02:00
Armin Ronacher
e15037478a Merge pull request #425 from highlyunavailable/master
Fix literal \ characters at the end of a string
2015-07-26 19:45:25 +02:00
Markus Unterwaditzer
08652a147a Merge pull request #461 from StevenMaude/patch-1
Fix typo: "the iterates" > "that iterates"
2015-07-12 18:35:49 +02:00
Steven Maude
ea07af81bf Fix typo: "the iterates" > "that iterates"
In filters.py.
2015-07-11 23:01:08 +01:00
Markus Unterwaditzer
fd7970ca83 Fix syntax error 2015-06-01 18:58:06 +02:00
Markus Unterwaditzer
06a8f5b75c Update FAQ about unsupported Python versions
Thanks to @ThomasWaldmann for the original patch. His fork is gone so I
can't apply the original commits.
2015-06-01 17:15:43 +02:00
Markus Unterwaditzer
62f57f4c18 Add Python classifiers for all supported versions
Thanks to @ThomasWaldmann for the original patch. His fork is gone so I
can't apply the original commits.
2015-06-01 17:12:56 +02:00
Markus Unterwaditzer
9620b9b08c Changelog for #447 2015-06-01 17:08:28 +02:00
Markus Unterwaditzer
3bb8a1f826 Merge pull request #447 from bentimms/int-filter-base
Add 'base' parameter to 'int' filter
2015-06-01 17:08:01 +02:00
Markus Unterwaditzer
d2ffef5813 Merge pull request #450 from jenisys/fixdoc.extension_example
FIX DOC-EXAMPLE: cache_extension.py
2015-06-01 17:07:42 +02:00
Markus Unterwaditzer
676fd8c6b2 Sort filters, remove dupes
Fix #454
2015-06-01 17:07:18 +02:00
Markus Unterwaditzer
45fe80e8a3 Merge branch 'merwok-patch-1'
Fix #455
2015-06-01 17:05:41 +02:00
Éric Araujo
f6b654de61 Fix typo 2015-06-01 17:05:27 +02:00
Armin Ronacher
46acbf02ed Escape slashes in query strings. This fixes #445 2015-05-25 13:40:47 +02:00
Armin Ronacher
0bfb60f831 Merge branch 'pr/451' 2015-05-25 12:25:02 +02:00
Armin Ronacher
0c1f192670 Added decorator support for finalize. This fixes #431 2015-05-25 12:24:09 +02:00
Markus Unterwaditzer
84f39ff5af Amend to #453 2015-05-17 17:58:09 +02:00
Markus Unterwaditzer
d9346a8a78 Merge pull request #453 from jeffwidman/patch-1
Fix typos and grammar in Readme
2015-05-17 17:55:23 +02:00
Jeff Widman
cdad3e6557 Fix typos and grammar in Readme 2015-05-16 22:51:49 -07:00
Antti Haapala
f4ddad8b44 fix the fancy tracebacks on Python 3 2015-05-10 10:04:15 +03:00
jenisys
fa3a3022cd FIX EXAMPLE:
No longer working with current code base
since the TokenStream.next() method was removed.
2015-05-09 18:57:52 +02:00
Ben Timms
97a8aafb8d Add 'base' parameter to 'int' filter 2015-04-29 16:45:46 +01:00
Josh Mize
62e7e70834 Make title filter capitalize words in (),{},[],<> 2015-04-08 16:49:32 -05:00
Markus Unterwaditzer
bd93bf3511 Merge branch 'override-codegen-context' 2015-04-06 14:28:25 +02:00
Markus Unterwaditzer
8f7290a005 Add changelog for #404 2015-04-06 14:27:03 +02:00
ThiefMaster
f22fdd5ffe Let the Environment override the Context
closes #404
2015-04-06 14:19:43 +02:00
ThiefMaster
14936312c0 Let the Environment override the CodeGenerator
see #404
2015-04-06 14:17:19 +02:00
Markus Unterwaditzer
a0d47b9cf9 Merge pull request #437 from alexwlchan/master
Fix a few small typos in the docs
2015-04-06 08:52:33 +02:00
Alex Chan
972c030552 Fix a few small typos in the docs 2015-04-05 22:42:34 +01:00
Markus Unterwaditzer
502050c9dc Merge branch '2.7-maintenance' 2015-04-02 02:02:03 +02:00
Markus Unterwaditzer
e1184d251a Fix syntax error 2015-04-02 02:01:35 +02:00
Markus Unterwaditzer
63018b5825 Merge branch '2.7-maintenance' 2015-04-02 01:54:08 +02:00
Markus Unterwaditzer
1ae49941f8 Fix #433 2015-04-02 01:52:52 +02:00
Markus Unterwaditzer
eb8f0e0305 Actually don't run doctests 2015-03-22 14:36:42 +01:00
Markus Unterwaditzer
a1fb63c7ad Fix travis 2015-03-22 14:32:16 +01:00
Markus Unterwaditzer
0349f9bfd0 Add build badges 2015-03-22 14:31:39 +01:00
Kartheek Lenkala
29b08c85a2 change py2 print statements to py3 2015-03-22 14:25:15 +01:00
Markus Unterwaditzer
599c1360bc Fix doctests
Fix #427
2015-03-22 14:22:52 +01:00
Markus Unterwaditzer
1c5f1e8d85 Merge branch 'lkarthee-pytest_migration' 2015-03-22 13:48:17 +01:00
Markus Unterwaditzer
3223751c33 Exclude examples 2015-03-22 13:46:22 +01:00
Markus Unterwaditzer
67da73fc6b Use tox in travis 2015-03-22 13:46:08 +01:00
Kartheek Lenkala
ee2cb97449 Rename testsuite to tests and suggestions
Remove  py.test from setup.py install_requires
Rename testsuite folder to tests.
2015-03-22 18:03:14 +05:30
Kartheek Lenkala
e33a018d7a Moving testsuite directory to root folder 2015-03-22 17:01:50 +05:30
Kartheek Lenkala
4d16c36170 fixing errors due to removal of init.py from test suite 2015-03-22 16:38:08 +05:30
Kartheek Lenkala
01b047c416 Adding pytest references and dependencies in setup.py and Makefile 2015-03-22 16:20:41 +05:30
Kartheek Lenkala
ddfa88306d Pytest Initial Commit 2015-03-22 15:38:05 +05:30
Kartheek Lenkala
9d4afa1160 Pytest migration initial commit 2015-03-22 15:28:54 +05:30
highlyunavailable
e0615edb75 Fix literal \ characters at the end of a string
Given a statement like `{% set sep = '\\' %}`, the syntax highlighter was considering the literal `'\\'` to be a literal quote inside the string by matching `\'` and thus highlighting the rest of the entire document as a string.

This change fixes that issue by adding some regex to ensure that an escaped quote is preceded by an uneven number of slashes (that is, `'\\\\\''` would accept the literal string `\\'` without issues). A`"` quoted string is modified the same way.
2015-03-20 11:50:14 -07:00
Markus Unterwaditzer
1b7a7f4f2f Merge pull request #254 from yoloseem/master
Duplication of index and search links on main page of documentation.
2015-03-11 21:33:16 +01:00
Markus Unterwaditzer
067f0c4e20 Merge branch '2.7-maintenance' 2015-03-11 21:32:16 +01:00
Markus Unterwaditzer
a1f76f92a1 Import from correct location.
Fix #259
2015-03-11 21:29:35 +01:00
Markus Unterwaditzer
cf43b5c606 Merge pull request #275 from yoloseem/patch-1
Fixed typos on docstrings of template filters.
2015-03-11 21:28:21 +01:00
Markus Unterwaditzer
376a7a5452 Merge pull request #343 from joernhees/patch-1
Custom Filters example inserts escaped <br>s
2015-03-11 21:28:01 +01:00
Markus Unterwaditzer
6363243f3f Merge pull request #344 from walterl/master
Added ".. versionadded:: 2.8" to `equalto` test
2015-03-11 21:27:41 +01:00
Markus Unterwaditzer
714ee3fada Merge pull request #345 from hszcg/patch-1
Fix missing " in docs/tricks.rst
2015-03-11 21:27:25 +01:00
Markus Unterwaditzer
b1851eb649 Merge branch 'adamchainz-master' 2015-03-11 21:26:50 +01:00
Markus Unterwaditzer
f1668bd26e Clarify sentence 2015-03-11 21:26:24 +01:00
Markus Unterwaditzer
0b49f13fd1 Merge pull request #375 from zart/fix-relative-search-on-windows
Windows returns EINVAL on bogus filenames
2015-03-11 21:19:52 +01:00
Markus Unterwaditzer
d97db3fdd9 Merge pull request #370 from BillyWM/patch-1
fix typo "makes sense to defined" -> define
2015-03-11 21:19:34 +01:00
Markus Unterwaditzer
c837008826 Merge pull request #362 from topher86/patch-1
Update djangojinja2.py
2015-03-11 21:19:27 +01:00
Markus Unterwaditzer
15e78c630f Merge pull request #402 from quodlibetor/attr-filter-docstring-cleanup
Change attr filter example to match description
2015-03-11 21:19:10 +01:00
Markus Unterwaditzer
e2ec123cd3 Merge pull request #383 from rbtcollins/patch-1
fix trivial typo (side -> size)
2015-03-11 21:18:33 +01:00
Markus Unterwaditzer
92278b782f Merge pull request #381 from ubershmekel/patch-1
A double quote is missing
2015-03-11 21:18:01 +01:00
Markus Unterwaditzer
c890d9d71f Merge pull request #388 from olegpesok/truncateDocFix
Fix incorrect truncate filter docs
2015-03-11 21:17:44 +01:00
Markus Unterwaditzer
242cd2c521 Merge pull request #403 from whit537/patch-1
trim obsolete sentence re: i18n extension
2015-03-11 21:17:28 +01:00
Markus Unterwaditzer
f9d804ead7 Merge pull request #400 from scavpy/scavpy-patch-1
Replace lambda for 'dict' in with dict itself
2015-03-11 21:17:01 +01:00
Markus Unterwaditzer
cb4b897bc3 Merge pull request #395 from esonderegger/master
Updated template documentation examples
2015-03-11 21:16:25 +01:00
Markus Unterwaditzer
e5de47f5a1 Merge pull request #397 from utzig/master
Fix typo
2015-03-11 21:16:10 +01:00
Markus Unterwaditzer
dd31dbad69 Merge pull request #398 from cerivera/master
grammar fix
2015-03-11 21:15:58 +01:00
Markus Unterwaditzer
1f3a09b913 Merge branch 'westurner-patch-1' 2015-03-11 21:12:56 +01:00
Markus Unterwaditzer
0ce1bca4a7 A few nitpicks 2015-03-11 21:12:47 +01:00
Markus Unterwaditzer
7ecfbe8b76 We don't want to give a specific recommendation. 2015-03-11 20:58:42 +01:00
Markus Unterwaditzer
459b908bff Not only syntax is affected. 2015-03-11 20:56:40 +01:00
Tim Bray
cdeaa33d0f decimal is a number 2015-03-11 16:11:00 +01:00
Markus Unterwaditzer
2f8b7cfc89 Merge pull request #418 from toanant/patch-1
Typo Fixed.
2015-03-07 13:26:10 +01:00
Abhishek Kumar Singh
8a2f69a25e Typo Fixed. 2015-03-07 17:38:32 +05:30
Markus Unterwaditzer
9e8a9b8974 Merge pull request #413 from hmeine/master
fix copy-pasted typo in filter docstrings
2015-02-26 18:23:47 +01:00
Hans Meine
c251d8a577 fix copy-pasted typo in filter docstrings 2015-02-26 15:36:51 +01:00
Markus Unterwaditzer
d0b35415ad Merge pull request #239 from msabramo/tox_posargs
tox.ini: Use {posargs} so that test runner arguments can be passed to tox
2015-02-26 10:49:22 +01:00
Markus Unterwaditzer
a0b863eed0 Merge pull request #405 from ThiefMaster/default-params-fix
Disallow f(x, y=1, z) and similar nonsense
2015-02-06 18:18:41 +01:00
ThiefMaster
e41e76cd33 Disallow f(x, y=1, z) and similar nonsense
Python rejects such function definitions because it doesn't make much
sense to have arguments with no default values after arguments with
default values.

Jinja did allow them, but handled them improperly (associating the
default value with the wrong argument).

Due to how broken the current behavior is, it makes more sense to reject
templates containing such defintions instead of trying to handle them
properly. Both cases are going to break existing code containing such
definitions, but besides the fact that possibly no such code exists it
is better to fail with a clear error than to silently change the values
of arguments.

This fixes #364
2015-02-06 18:18:07 +01:00
Markus Unterwaditzer
c6c6ea1437 Merge pull request #406 from ThiefMaster/number-test-fix
Fix `long_integer is number` check in Python 2
2015-02-06 18:12:29 +01:00
Markus Unterwaditzer
d09edda04a deduplicate version info 2015-02-06 18:11:55 +01:00
Markus Unterwaditzer
781e00e81f Remove automatic dev version generating 2015-02-06 18:09:59 +01:00
Markus Unterwaditzer
a6933f3fd4 Merge pull request #407 from ThiefMaster/pep-440-dev-version
Use PEP440-compatible dev version
2015-02-06 18:06:35 +01:00
ThiefMAster
0c7c3823fe Use PEP440-compatible dev version 2015-02-06 17:05:18 +01:00
ThiefMaster
1e73c09137 Add float/complex testcases for is number 2015-02-06 01:12:09 +01:00
ThiefMaster
9bf5fcbb3b Fix number test failing for long in Python 2 2015-02-06 01:09:13 +01:00
Chad Whitacre
e53659d0d5 trim obsolete sentence re: i18n extension
This sentence seems like a leftover from when i18n was the only extension available, eh?
2015-02-05 14:53:19 -05:00
Brandon W Maister
9443b3cd70 Change attr filter example to match description
foo["bar"] is an item lookup, so saying that items are not looked
up with that as an example is confusing.
2015-02-05 14:49:30 -05:00
Peter Harris
6179c02c91 Replace lambda for 'dict' in with dict itself
lambda **kw: kw is not equivalent to the dict constructor. It is much less useful.
In particular it doesn't accept a sequence of pairs.
Why not put dict itself into the DEFAULT_NAMESPACE?
Principle of least surprise, etc.
2015-01-23 10:12:10 +00:00
Carlos Eduardo Rivera
cf845c99ef grammar fix 2015-01-18 20:22:34 -06:00
Fabio Utzig
c0734709b3 Fix typo 2015-01-18 17:29:18 -02:00
Evan Sonderegger
b8230a73bb Updated template documentation examples
Fixed html tags in base template example. Since I was removing the
xmlns="http://www.w3.org/1999/xhtml" tag, it seemed like a good time to
update the examples to the html5 doctype.
2015-01-07 20:01:40 -05:00
Wes Turner
d40e9ba0fc DOC: Update templates.rst: syntax, commas 2014-12-11 09:57:11 -06:00
Oleg Pesok
4e7f44ad07 Fix incorrect truncate filter docs
Examples contrary to behavior and description of killwords argument.
2014-12-10 17:16:25 -08:00
rbtcollins
960138bd15 fix trivial typo (side -> size) 2014-11-21 10:35:32 +13:00
Yuval Greenfield
a002727db3 A double quote is missing 2014-11-06 09:31:32 -08:00
Konstantin Zemlyak
0b74a4f07d Windows returns EINVAL on bogus filenames
Related pull of pyramid_jinja2: https://github.com/Pylons/pyramid_jinja2/pull/94
2014-09-28 21:08:28 +06:00
William Wenge-Murphy
de08e059a6 fix typo "possible to defined" -> define 2014-09-20 18:11:28 -07:00
topher86
074132908f Update djangojinja2.py
Updating to reflect new default global cache size
2014-08-28 13:37:41 -04:00
Armin Ronacher
85820fceb8 Increased cache size to 400. 2014-08-28 09:10:22 +02:00
Adam Chainz
382ee7019f Switching docs tweaks 2014-07-12 23:03:55 +01:00
Chenguang Zhang
183e4787b2 Fix missing " in docs/tricks.rst 2014-06-24 16:04:35 +08:00
Walter Leibbrandt
5f748c34d6 Added ".. versionadded:: 2.8" to test_equalto.__doc__ 2014-06-19 00:29:42 +02:00
Jörn Hees
1702451edc Custom Filters example inserts escaped <br>s
The example nl2br custom filter inserts escaped `&lt;br&gt;` <br> tags as a `Markup.replace` method seems to be aware of modifications and pass `str`/`unicode` arguments through `escape`.
2014-06-15 18:31:16 +02:00
Armin Ronacher
c97fa109d3 Merge pull request #230 from p1otr/master
documentation typos
2014-06-10 21:34:12 +01:00
Armin Ronacher
ac168cadf5 Merge pull request #341 from apetresc/patch-1
Fixing dead link to documentation in README.rst
2014-06-09 21:59:04 +01:00
Adrian Petrescu
1a87fc1be2 Fixing dead link to documentation in README.rst
Current link works as of June 9th, 2014.
2014-06-09 16:55:03 -04:00
Armin Ronacher
3d91ae5fff Documented {% set %}...{% endset %} 2014-06-07 00:58:38 +06:00
Armin Ronacher
9bf94b533d Implemented a block set tag. 2014-06-07 00:56:05 +06:00
Armin Ronacher
f0c987bef4 Flake 8 fixes 2014-06-06 23:10:07 +06:00
Armin Ronacher
76402dccca Removed unused variable 2014-06-06 23:05:04 +06:00
Armin Ronacher
718505778e Merge pull request #274 from thomasballinger/fix-1
docfixes in Variables section of templates.rst
2014-06-06 22:57:54 +06:00
Armin Ronacher
0d52d72c46 Merge pull request #284 from LucianU/patch-1
Spelling, grammar, and punctuation fixes to extensions docs.
2014-06-06 22:57:36 +06:00
Armin Ronacher
6a04a8b78d Merge pull request #293 from carldunham/docfix
fixed some typos and clarifying
2014-06-06 22:55:39 +06:00
Armin Ronacher
9ff7de95f3 Added changelog entry on last commit 2014-06-06 22:55:20 +06:00
Armin Ronacher
8a0358e79b Merge pull request #282 from timhanus/master
force a reload of the template if bytecode fails to unmarshall.  issue #...
2014-06-06 22:54:51 +06:00
Armin Ronacher
f5a80033f7 Merge pull request #287 from omh/master
Fixed typo (igored -> ignored)
2014-06-06 22:54:21 +06:00
Armin Ronacher
99e46a0744 Merge branch '2.7-maintenance' 2014-06-06 22:51:59 +06:00
Armin Ronacher
8fc231a119 Ready for 2.7.4 2014-06-06 22:49:44 +06:00
Armin Ronacher
762c612e72 Bump version number to 2.7.3 2014-06-06 22:49:12 +06:00
Armin Ronacher
f8bca1392a Added changelog entry 2014-06-06 22:49:07 +06:00
Tomas Hoger
964c61ce79 Fix CVE-2014-0012
Add checks for the per-user temporary directory.  If it already exists, make
sure that it:
- is owned by the current user
- is directory
- has expected permissions

This commit also fixes:
- nt -> n typo pointed out in the review of acb672b
- replace 448 with stat.S_IRWXU when setting directory mode

Signed-off-by: Armin Ronacher <armin.ronacher@active-4.com>
2014-06-06 22:47:51 +06:00
Armin Ronacher
377b9b55f3 Applied changes from #296 for better checking. 2014-06-06 22:44:49 +06:00
Armin Ronacher
73f27f5b32 Make sure filtering returns a list for template listing. 2014-06-06 22:40:02 +06:00
Armin Ronacher
cb6fab73c6 Fixed #320 2014-06-06 22:31:00 +06:00
Armin Ronacher
74a809e5b4 Merge pull request #312 from fengsp/master
Removed duplication from ignored_tokens in lexer
2014-06-06 22:18:27 +06:00
Armin Ronacher
fff365eb0b Merge pull request #310 from vivekagr/patch-1
Fix typo.
2014-06-06 22:18:06 +06:00
Armin Ronacher
7b32f8f8d1 Fixed a Python 3 regression. 2014-06-06 22:17:05 +06:00
Armin Ronacher
6e9dfbf2de Added tests for logging undefined and added it to the docs. 2014-06-06 22:14:45 +06:00
Armin Ronacher
d2641be848 Added support for logging of undefined objects.
fixup!

fixup!
2014-06-06 22:01:35 +06:00
Armin Ronacher
e7a9b947e0 Added changelog for #304 fix. 2014-06-06 21:49:37 +06:00
Armin Ronacher
06badebe3b Fix for #304 2014-06-06 21:49:37 +06:00
Armin Ronacher
c8c70ff597 Merge pull request #324 from br0p0p/patch-1
Update Jinja2 tip link
2014-06-06 21:38:55 +06:00
Armin Ronacher
a9895c88f6 Merge branch 'pr/314' 2014-06-06 21:37:47 +06:00
Armin Ronacher
dd11bcd732 Added changelog entry 2014-06-06 21:36:53 +06:00
Armin Ronacher
e2e34a0ec1 Merge pull request #315 from lazka/fix-iter-length
Fix loop context length calculation for iterators. Fixes #244
2014-06-06 21:36:26 +06:00
Armin Ronacher
65ae6e20ac Merge pull request #317 from shedokan/master
Improved performance of filters.do_truncate()
2014-06-06 21:36:08 +06:00
Armin Ronacher
4f028a808c Merge pull request #319 from richierichrawr/master
Edit code comments for readability
2014-06-06 21:35:56 +06:00
Armin Ronacher
bd0f6c07d1 Added 3.4 to tox 2014-06-06 21:33:07 +06:00
Armin Ronacher
59bbcfa771 Added 3.4 to travis 2014-06-06 21:32:57 +06:00
Armin Ronacher
641c04126c Style cleanups in environment and a tiny bugfix. 2014-06-06 21:31:06 +06:00
Armin Ronacher
e7086dbdb8 Fixed issue #309 2014-06-06 21:30:53 +06:00
Armin Ronacher
888e6755d4 More resilient template directory handling for bytecode cache. 2014-06-06 21:28:09 +06:00
Armin Ronacher
4dd06e72c3 Merge pull request #331 from SteelyWing/patch-1
fix os.name of Windows
2014-06-06 21:23:30 +06:00
Armin Ronacher
72a93c8e73 Added changelog entry 2014-06-06 21:23:13 +06:00
Armin Ronacher
86b4b38dee Merge pull request #332 from SteelyWing/patch-2
Use abs path for cache key
2014-06-06 21:22:27 +06:00
Armin Ronacher
5f710a9039 Merge pull request #333 from SteelyWing/patch-3
close temp file
2014-06-06 21:20:11 +06:00
Armin Ronacher
76c3995fbc Merge pull request #336 from berkerpeksag/wheel-support
Add wheel support.
2014-06-06 21:19:56 +06:00
Armin Ronacher
e1e5c0fa6e Merge pull request #337 from berkerpeksag/delete-with-speedups-warning
Delete the ignore --with-speedups message.
2014-06-06 21:19:40 +06:00
Berker Peksag
fb470a2cd8 Delete the ignore --with-speedups message.
The with-speedups flag was deprecated 4 years and
3 major releases ago.
2014-05-19 06:55:02 +03:00
Berker Peksag
685d2ad34e Add wheel support. 2014-05-19 06:48:10 +03:00
Wing
090680f3d5 better assignment 2014-05-17 14:30:34 +08:00
Wing
1abbe4dd84 check for if loader does not implement get_source() 2014-05-17 13:42:53 +08:00
Wing
6b990c117a close temp file
The test can't remove the temp file on Windows, because `mkstemp()` will open the temp.
2014-05-17 13:18:39 +08:00
Wing
15c02ae4d7 if template is not file, use name for cache key 2014-05-17 12:49:49 +08:00
Wing
9fe850dfd3 Update environment.py 2014-05-17 03:52:50 +08:00
Wing
115aa96261 Update environment.py 2014-05-17 03:52:11 +08:00
Wing
6671b973e6 use abs path for cache key 2014-05-17 03:36:57 +08:00
Wing
25d83a4102 fix os.name of Windows
os.name of Windows is 'nt', https://docs.python.org/3.4/library/os.html#os.name
2014-05-17 03:27:05 +08:00
Caleb Williams
dd0f39854f Update Jinja2 tip link 2014-04-16 23:44:56 -05:00
Armin Ronacher
b7d13f2787 Switch to new server 2014-04-07 23:25:37 +02:00
richierichrawr
c268e74ef3 Edit code comments for readability
Changed a few things to make it more understandable
2014-04-05 16:33:51 -04:00
Eric Sh
10a10adc03 Improved performance of filters.do_truncate() 2014-04-03 14:19:05 +03:00
Christoph Reiter
4eb30f1dec Fix loop context length calculation for iterators. Fixes #244
This resulted in wrong values for revindex and revindex0
while looping over an iterator.
2014-03-30 17:40:08 +02:00
fsp
48196fb4f8 Fixed typo 2014-03-30 14:18:10 +08:00
fsp
7c83462a61 Removed duplication from ignored_tokens in lexer 2014-03-18 13:56:29 +08:00
Vivek Agarwal
972feb4da2 Fix typo. 2014-03-12 20:26:03 +05:30
Carl A Dunham
d546358cf5 fixed some typos and clarifying 2014-01-18 15:26:10 -06:00
Armin Ronacher
27ffd01f95 Merge branch '2.7-maintenance' 2014-01-10 10:43:55 +00:00
Armin Ronacher
5662125f79 This is 0.7.3-dev 2014-01-10 10:43:07 +00:00
Armin Ronacher
91fa138077 Bump version number to 2.7.2 2014-01-10 10:42:33 +00:00
Armin Ronacher
f25707c420 Fixed a syntax error on Python 3 2014-01-10 10:42:24 +00:00
Armin Ronacher
f18deb623c Release 2.7.2 today 2014-01-10 10:41:28 +00:00
Armin Ronacher
acb672b6a1 Fixed a security issue with temporary files on the filesystem cache on UNIX. 2014-01-10 10:40:51 +00:00
Ole Morten Halvorsen
02123ffb67 Fixed typo (igored -> ignored) 2013-12-30 23:37:23 +11:00
Armin Ronacher
f6c6fe4382 Added a note on why equalto exists. 2013-12-12 22:32:44 +00:00
Armin Ronacher
7d3e4e4ed0 Added a changelog entry for the equalto filter 2013-12-12 22:30:24 +00:00
Armin Ronacher
510fb489d6 Merge branch 'pr/283' 2013-12-12 22:29:46 +00:00
Armin Ronacher
d47b4d7dee Added changelog entry for truncate filter 2013-12-12 22:28:21 +00:00
Armin Ronacher
daf34166be Merge branch 'pr/267' 2013-12-12 22:27:53 +00:00
Armin Ronacher
f058cadfbb Added and corrected changelog entry 2013-12-12 22:27:28 +00:00
Armin Ronacher
157cce7076 Merge branch 'pr/266' 2013-12-12 22:26:58 +00:00
Armin Ronacher
853d8654ad Added changelog entry 2013-12-12 22:26:29 +00:00
Lucian Ursu
07497dcf60 Spelling, grammar, and punctuation fixes to extensions docs. 2013-11-29 14:16:06 +02:00
Tim Hanus
23551a53cd explicitly catch marshal errors rather than genertic exception #281 2013-11-22 10:18:25 -06:00
Thomas van Noort
40367c48bb Define tests for equalto. 2013-11-22 13:50:51 +01:00
Thomas van Noort
9c89bbbec7 Add equalto test as value-level analogue of reference-level sameas test. 2013-11-22 12:24:52 +01:00
Tim Hanus
f00ded9d66 force a reload of the template if bytecode fails to unmarshall. issue #281 2013-11-21 13:15:57 -06:00
Hyunjun Kim
e351f674e6 Fixed typos on docstrings of template filters.
appying -> applying
2013-11-01 13:49:34 +09:00
Thomas Ballinger
f30ab12302 docfixes in Variables section of templates.rst
I was distracted by "alternative" -> alternatively, then changed other bits and pieces in the section.
fixes suggested by @Naddiseo, and clarify that "what a variable looks like" really means "what attributes a variable has."
2013-10-28 16:59:48 -04:00
Marc Abramowitz
8d24e0c6d2 Merge branch 'master' into tox_posargs 2013-10-16 16:52:43 -07:00
Berker Peksag
3c75c961b4 Issue #121: The truncate filter now counts the length
of the *end* parameter when truncating a string.

This is the same behavior as Django's truncate filter:

https://docs.djangoproject.com/en/1.4/ref/templates/builtins/#truncatechars
2013-09-14 01:09:52 +03:00
Berker Peksag
1eeaccc94b Issue #71: Add followlinks parameter to FileSystemLoader. 2013-09-13 22:41:33 +03:00
Berker Peksag
d55e1e59c1 Issue #126: Add target keyword argument to urlize. 2013-08-21 13:23:47 +03:00
Armin Ronacher
63227f05c5 Merge branch '2.7-maintenance' 2013-08-07 16:04:01 +01:00
Armin Ronacher
701e9ada2b Fixed prefix loader now properly forward globals.
This fixes #238
2013-08-07 16:01:00 +01:00
Armin Ronacher
c6519c1f5c Prepared a changelog entry 2013-08-07 15:59:07 +01:00
Armin Ronacher
8db47916de Merge branch '2.7-maintenance' 2013-08-07 14:28:50 +01:00
Armin Ronacher
8b0c37c3cd Ready for another release 2013-08-07 14:27:53 +01:00
Armin Ronacher
770f929cff Bump version number to 2.7.1 2013-08-07 14:27:31 +01:00
Armin Ronacher
078a0bb612 Fixed release script 2013-08-07 14:25:19 +01:00
Armin Ronacher
7253ca41ed Bugfix release is today 2013-08-07 13:04:00 +01:00
Armin Ronacher
2ea663b17f Corrected title filter behavior.
The title filter will now correctly lowercase the non first letter
like the regular Python filter does.

This fixes #251.
2013-08-07 12:53:03 +01:00
Armin Ronacher
563fd2e74a Fixed warnings if Python is run with -3.
This also adds proper hashing and comparision support to
undefined objects.

This fixes #224
2013-08-07 12:48:37 +01:00
Armin Ronacher
ad09fe32dd Added changelog note 2013-08-07 12:41:56 +01:00
Armin Ronacher
59713a3acf Revert "Support included blocks override"
This reverts commit 33aee12a29.

This fixes #243.
2013-08-07 12:40:59 +01:00
Armin Ronacher
d65f40f90c Merge branch '2.7-maintenance' 2013-08-07 12:31:17 +01:00
Armin Ronacher
3d82fc3d14 Added changelog entry 2013-08-07 12:31:07 +01:00
Marc Abramowitz
dc3b431829 Fix Python 3 compatibility of BytecodeCache by checking for `if
isinstance(filename, text_type)` instead of `if isinstance(filename,
unicode)`
2013-08-07 12:30:38 +01:00
Marc Abramowitz
10707853c4 Add test (jinja2.testsuite.bytecode_cache.ByteCodeCacheTestCase) for
BytecodeCache that fails on Python 3 because it uses `unicode`
2013-08-07 12:30:32 +01:00
Hyunjun Kim
95e583ae72 Remove index and search function from contents.rst.inc 2013-07-16 19:23:59 +09:00
Armin Ronacher
4c7b51bbd0 Merge branch '2.7-maintenance' 2013-07-04 16:25:55 +02:00
Armin Ronacher
342e88a6c4 Fixed a bug with call_filter not working properly 2013-07-04 16:25:04 +02:00
Armin Ronacher
5ca25297d0 Started 2.7 maintenance branch 2013-07-04 16:24:31 +02:00
Marc Abramowitz
10d14f2175 tox.ini: Use {posargs} so that test runner arguments can be passed to
tox

E.g.: tox -e py26 -- -v jinja2.testsuite.core_tags
2013-06-05 22:23:48 -07:00
Armin Ronacher
8261473c68 Fixed some incorrect docs 2013-06-05 10:33:02 +01:00
Armin Ronacher
73c34f5a99 Merge branch 'master' of github.com:mitsuhiko/jinja2 2013-05-31 01:00:56 +01:00
Armin Ronacher
de1405fc78 Let travis notify the #pocoo irc channel 2013-05-31 01:00:45 +01:00
Armin Ronacher
147472a270 Merge pull request #236 from johnboxall/title-filter-with-objects
`title` filter should accept objects.
2013-05-28 17:37:41 -07:00
John Boxall
2fff653c09 filter should accept objects. 2013-05-28 17:06:22 -07:00
Jakub Wilk
3fc008b629 fix a bunch of typos in the documentation 2013-05-25 23:39:03 +02:00
Armin Ronacher
073fdc0a52 Merge pull request #226 from dzen/master
Fix MarkupSafe dependancy case
2013-05-22 06:27:51 -07:00
Benoit Calvez
70a2bc0e58 Fix MarkupSafe case in setup.py
Most of pypi mirrors don't allow wrong package name case when installing
them using pip
example: c.pypi.python.org

I know, this is very painful
2013-05-22 14:39:44 +02:00
Armin Ronacher
f15b814dcb Removed some no longer needed code from compat 2013-05-20 17:06:41 +01:00
Armin Ronacher
1c5315a0b3 Removed duplication from types that was only necessary for IronPython 2013-05-20 17:03:46 +01:00
Armin Ronacher
b89d1a8fe3 Since we no longer support 2.5 we can use the builtin next() function 2013-05-20 16:54:48 +01:00
Armin Ronacher
da94a8b504 Fixed docs not building 2013-05-20 14:06:59 +01:00
Armin Ronacher
d25577b43f This is now 2.8-dev 2013-05-20 14:04:11 +01:00
Armin Ronacher
6e17e7dcd0 Bump version number to 2.7 2013-05-20 14:02:56 +01:00
Armin Ronacher
fc9b2db7b2 Fixed a release script and added a release date 2013-05-20 14:02:53 +01:00
Armin Ronacher
8020d0209e Make travis execute make test instead of setup.py test 2013-05-20 12:18:35 +01:00
Armin Ronacher
d76b8da0d2 Clarified some text in the intro 2013-05-20 12:15:50 +01:00
Armin Ronacher
dec91944ee Disable py_compile for Python 3 and pypy 2013-05-20 12:11:02 +01:00
Armin Ronacher
54c9f93e1f Added nicer test finder from Flask 2013-05-20 11:51:37 +01:00
Armin Ronacher
3b76f0441d Updated makefile with tox and develop command 2013-05-20 11:44:15 +01:00
Armin Ronacher
542e3c8738 Actually remove argument in setup.py for speedups 2013-05-20 09:49:40 +01:00
Armin Ronacher
568352e07d Documented loop.depth and added loop.depth0. 2013-05-20 09:26:57 +01:00
Armin Ronacher
dcd0cb7312 Changed lookup logic for make_attrgetter to support integers like the regular syntax 2013-05-20 09:07:08 +01:00
Armin Ronacher
03bea567c7 Renamed helper classes in with_metaclass 2013-05-20 09:00:04 +01:00
Armin Ronacher
994404a692 Added missing method for template errors 2013-05-20 02:21:17 +01:00
Armin Ronacher
a4a245c56b Removed some dead imports 2013-05-20 02:19:35 +01:00
Armin Ronacher
daa36a6f32 Unified constructor for template errors between 2.x and 3.x 2013-05-20 02:18:47 +01:00
Armin Ronacher
ff0b5f5836 feature to version check for context dict methods 2013-05-20 02:15:04 +01:00
Armin Ronacher
146c9ba170 Corrected a newline 2013-05-20 02:13:15 +01:00
Armin Ronacher
eb12114219 Removed an unnecessary check 2013-05-20 02:12:34 +01:00
Armin Ronacher
ce779a585f More cleanup in the utils module 2013-05-20 02:11:16 +01:00
Armin Ronacher
41746b9246 Some more small cleanup for metaclasses 2013-05-20 02:05:48 +01:00
Armin Ronacher
fb4352de50 Disable module loader test case on pypy because they are not supported 2013-05-20 02:00:02 +01:00
Armin Ronacher
285c955921 Added an explanation for how with_metaclass works 2013-05-20 01:53:10 +01:00
Armin Ronacher
28c7488224 Make the runtime leak less of the version hacks 2013-05-20 01:51:26 +01:00
Armin Ronacher
25a67d0a14 Added .egg to .gitignore 2013-05-20 01:32:44 +01:00
Armin Ronacher
6b2eba516f Removed unnecessary del 2013-05-19 14:46:12 +01:00
Armin Ronacher
7e239b4d16 Added unicode mixin for unified string logic 2013-05-19 14:43:18 +01:00
Armin Ronacher
7e245e2678 PY3 -> PY2 macro 2013-05-19 14:34:54 +01:00
Armin Ronacher
630804f67d Rewrapped import 2013-05-19 14:23:30 +01:00
Armin Ronacher
444fec358c Unified version checks where appropriate 2013-05-19 14:22:08 +01:00
Armin Ronacher
e909867721 Moved all six usages (ignoring testsuite) into jinja2._compat 2013-05-19 14:16:13 +01:00
Armin Ronacher
cd7bf5b00f Removed mention of speedup module and rewrote docs for markupsafe dependency 2013-05-19 13:51:47 +01:00
Armin Ronacher
294f2ebff9 Removed bundled markupsafe 2013-05-19 13:49:12 +01:00
Armin Ronacher
4a41dd6753 Fixed a docstring and a syntax error on 3.3 2013-05-19 13:47:33 +01:00
Armin Ronacher
c87d4cf11f six.advance_iterator -> next 2013-05-19 13:46:22 +01:00
Armin Ronacher
5cf31686c3 Merge remote-tracking branch 'paradoxxxzero/include_fix' 2013-05-19 13:25:43 +01:00
Armin Ronacher
400f973c8d Fixed #79 2013-05-19 13:23:57 +01:00
Armin Ronacher
9417d01311 Merge remote-tracking branch 'apollo13/master' 2013-05-19 12:45:48 +01:00
Armin Ronacher
15e9eef380 Fixed a loop bug. This fixes #100 2013-05-19 12:44:50 +01:00
Armin Ronacher
e403e52f42 Merge pull request #112 from Cito/master
Addition/correction for pull request #69 - add note to docs
2013-05-19 04:31:48 -07:00
Armin Ronacher
fe63b44889 Merge remote-tracking branch 'Talksum/distribute_required' 2013-05-19 12:29:55 +01:00
Armin Ronacher
8eed53c958 Added support for map, select, reject, selectattr and rejectattr
filters.

This supercedes #66
2013-05-19 12:25:32 +01:00
Armin Ronacher
dc4b4cd034 Merge branch 'master' of github.com:mitsuhiko/jinja2 2013-05-19 11:37:01 +01:00
Armin Ronacher
4b2c926d9d Whitespace normalization 2013-05-19 11:36:52 +01:00
Armin Ronacher
d6892c583b Merge pull request #76 from kracekumar/master
Changed three to four in nodes.py at line no 107
2013-05-19 03:33:59 -07:00
Armin Ronacher
13340f9672 Flask -> Jinja2 2013-05-19 11:29:55 +01:00
Armin Ronacher
c5005a7edf Merge pull request #104 from njl/fix-issue-77
Fix issue #77
2013-05-19 03:29:35 -07:00
Armin Ronacher
55ea1df4c5 Merge pull request #94 from florentx/patch-1
Fix the Mako-like environment.
2013-05-19 03:29:15 -07:00
Armin Ronacher
3054985e76 Merge pull request #114 from cocoatomo/patch-1
There is no need to initialize Environment#bytecode_cache twice
2013-05-19 03:26:14 -07:00
Armin Ronacher
2609cb3a1c Merge pull request #138 from gazpachoking/default_fix
Prevent default filter from throwing UndefinedError
2013-05-19 03:25:40 -07:00
Armin Ronacher
8dc9d4d6cb Merge branch 'master' of github.com:mitsuhiko/jinja2 2013-05-19 11:18:59 +01:00
Armin Ronacher
a65f1eb906 Merge remote-tracking branch 'kristi/master' 2013-05-19 11:18:19 +01:00
Armin Ronacher
83f6a68912 Merge pull request #149 from dmedvinsky/patch-1
Fix typo in `include` documentation
2013-05-19 03:11:04 -07:00
Armin Ronacher
d754f8c2b1 Merge pull request #162 from mgax/fix-caching
fix DictLoader `uptodate` callback
2013-05-19 03:10:01 -07:00
Armin Ronacher
0a6f850d9a Merge branch 'master' of github.com:mitsuhiko/jinja2 2013-05-19 11:09:44 +01:00
Armin Ronacher
f3acf0b7b3 Merge remote-tracking branch 'wking/keep-trailing-newline' 2013-05-19 11:09:19 +01:00
Armin Ronacher
604752bb83 Merge pull request #165 from AquarHEAD/master
Update the Docstring of do_truncate in jinja2/filters.py
2013-05-19 03:07:28 -07:00
Armin Ronacher
7e2b823af6 Merge pull request #159 from myle/patch-1
Update docs/templates.rst
2013-05-19 03:07:11 -07:00
Armin Ronacher
257a8cdc1e Merge pull request #141 from dgilman/patch-1
Fix FAQ typo
2013-05-19 03:06:52 -07:00
Armin Ronacher
b418550f25 Merge pull request #173 from kracekumar/patch-1
Update jinja2/filters.py
2013-05-19 03:06:39 -07:00
Armin Ronacher
840e7e060e Added a way to disable memcache error ignoring and documented the change. Also changed a bare except to an except on the exception type. 2013-05-19 11:06:18 +01:00
Armin Ronacher
8fea62d44b Merge remote-tracking branch 'kadams54/master' 2013-05-19 11:04:40 +01:00
Armin Ronacher
96512acabd Merge pull request #203 from aspiers/master
Prevent line statements eating newlines (fixes #52)
2013-05-19 03:03:50 -07:00
Armin Ronacher
c64cc50eda Merge pull request #166 from rtorr/patch-1
Update docs/tricks.rst
2013-05-19 03:03:06 -07:00
Armin Ronacher
e5ea6f8e23 Removed dummy readme 2013-05-18 14:31:47 +01:00
Armin Ronacher
f676ea3ef8 Merge pull request #222 from mgax/exception-messages
Python 3 exceptions can handle unicode messages
2013-05-18 05:58:06 -07:00
Armin Ronacher
8c9b16adca Removed a refrence to removed debugsupport in the manifest 2013-05-18 13:45:00 +01:00
Alex Morega
e29c84ccc0 Python 3 exceptions can handle unicode messages 2013-05-18 15:38:11 +03:00
Armin Ronacher
a1f2ee7112 xrange -> range_type for consistency 2013-05-18 13:05:01 +01:00
Armin Ronacher
84d5de2d51 Added 3.3 2013-05-18 12:58:29 +01:00
Armin Ronacher
8bdc65d9e5 Removed 2.5 for travis on the new branch 2013-05-18 12:45:13 +01:00
Armin Ronacher
64f6990c3b Merge branch 'master' into sprint-branch 2013-05-18 12:44:48 +01:00
Armin Ronacher
5447aa736a Fixed MethodType being wrong on 3.x 2013-05-18 12:44:03 +01:00
Armin Ronacher
6c9e5aee4b Merge pull request #219 from sharoonthomas/master
Add Travis CI for master
2013-05-18 04:41:10 -07:00
Armin Ronacher
73721708ff Merge remote-tracking branch 'mgax/test-for-58d458d' into sprint-branch 2013-05-18 12:27:45 +01:00
Sharoon Thomas
2d71858593 Add Travis CI 2013-05-18 16:56:10 +05:30
Armin Ronacher
ab8991e5d9 Fixed a type in a module name. 2013-05-18 12:25:16 +01:00
Alex Morega
e9b4af6da6 unit test for dumping as utf-8 to a file 2013-05-18 14:23:37 +03:00
Armin Ronacher
f6b4b0442e Merge remote-tracking branch 'ThomasWaldmann/sprint-branch' into sprint-branch 2013-05-18 12:23:30 +01:00
Thomas Waldmann
05ace8b83e stuff missing from previous commit, thanks git 2013-05-18 13:14:14 +02:00
Armin Ronacher
4cd6e9a809 Merge branch 'master' into sprint-branch 2013-05-18 12:11:05 +01:00
Armin Ronacher
b9c76fb845 Merge pull request #163 from kuyan/patch-1
Fixed typo
2013-05-18 04:10:52 -07:00
Armin Ronacher
77e0fa2aec Merge pull request #188 from lemonad/master
Fixed typos: overriden to overridden
2013-05-18 04:10:40 -07:00
Thomas Waldmann
a2cf1d31ea new jinja2._compat module for stuff not yet in six 1.3.0 2013-05-18 13:08:53 +02:00
Armin Ronacher
e2fc8749bc Merge branch 'master' into sprint-branch 2013-05-18 12:07:34 +01:00
Armin Ronacher
728d69abad Added missing versionadded and changelog entry 2013-05-18 12:07:27 +01:00
Armin Ronacher
587d61b7f8 Merge branch 'master' of github.com:mitsuhiko/jinja2 2013-05-18 12:06:06 +01:00
Armin Ronacher
9aa4bddafa Merge pull request #206 from johnmcdonnell/wordwrap
Allow choice of wrap string in wordwrap filter.
2013-05-18 04:05:57 -07:00
Armin Ronacher
7e58e36cf4 Merge branch 'sprint-branch' of github.com:mitsuhiko/jinja2 into sprint-branch 2013-05-18 12:04:23 +01:00
Armin Ronacher
064ccaf7e3 Merge branch 'master' into sprint-branch 2013-05-18 12:04:19 +01:00
Armin Ronacher
a187737139 Merge pull request #216 from Lukasa/luk-sprint-branch
Sprint: Not supporting Python 2.4 is a blessing
2013-05-18 04:03:40 -07:00
Armin Ronacher
2b5b35a9f4 Whitespace cleanup 2013-05-18 12:02:11 +01:00
Cory Benfield
e8acd5b6b0 Python 2.6+ supports conditional expressions. 2013-05-18 12:00:14 +01:00
Cory Benfield
0d3b38911a BytesIO from six. 2013-05-18 12:00:13 +01:00
Armin Ronacher
e94dd1f288 Merge branch 'master' into sprint-branch 2013-05-18 11:59:23 +01:00
Armin Ronacher
2b0231c1d7 Merge pull request #202 from Necoro/master
Fix vim syntax: filters
2013-05-18 03:59:01 -07:00
Armin Ronacher
adb599994a Merge branch 'master' into sprint-branch 2013-05-18 11:58:37 +01:00
Armin Ronacher
9962c10b25 Cleanup and changelog entry for new contextfunction behavior 2013-05-18 11:58:12 +01:00
Armin Ronacher
9952041acd Merge pull request #200 from Naddiseo/callable_class_contextfunction
Callable class contextfunction, closes #180
2013-05-18 03:55:48 -07:00
Armin Ronacher
0c435ccb38 Merge pull request #215 from DasIch/remove-unused-imports
Remove unused imports
2013-05-18 03:53:55 -07:00
Daniel Neuhäuser
d0708db4bf Remove unused imports 2013-05-18 12:52:40 +02:00
Armin Ronacher
d77a031aaa Merge pull request #214 from Lukasa/luk-sprint-branch
Sprint: More misc fixes
2013-05-18 03:49:17 -07:00
Armin Ronacher
58d458dd62 Make dump() work Python 3.3 2013-05-18 11:46:35 +01:00
Armin Ronacher
e6c0630249 file -> open for 3.x support. This fixes #152 2013-05-18 11:44:49 +01:00
Cory Benfield
d5a0edfdaa Don't assign the range type each time. 2013-05-18 11:41:24 +01:00
Cory Benfield
b36039f0ca Correctly compare version type. 2013-05-18 11:40:52 +01:00
Armin Ronacher
d7d663f612 Cleanup up some imports 2013-05-18 11:38:34 +01:00
Armin Ronacher
755b6b7e84 Merge pull request #213 from Lukasa/luk-sprint-branch
Sprint: Misc fixes.
2013-05-18 03:37:18 -07:00
Armin Ronacher
9dd7fadce7 Fixed a check that broke pypy 2013-05-18 11:36:32 +01:00
Armin Ronacher
788fd1ccb3 Added .tox to .gitignore 2013-05-18 11:36:26 +01:00
Armin Ronacher
f2c937e691 Merge pull request #212 from DasIch/add-tox
Add tox configuration
2013-05-18 03:32:21 -07:00
Cory Benfield
02a4654fb3 No need for tuple comparisons. 2013-05-18 11:30:08 +01:00
Cory Benfield
86e5f97fc2 We don't support 2.4 anymore. 2013-05-18 11:30:07 +01:00
Daniel Neuhäuser
69b4b0a6b5 Add tox configuration 2013-05-18 12:29:58 +02:00
Armin Ronacher
28579a6bff A bit of cleanup in the environment 2013-05-18 11:18:57 +01:00
Armin Ronacher
6d11d17fd5 Merge pull request #207 from ekalinin/patch-1
Fixed improperly closed tag in menu example in tricks.rst
2013-05-18 03:13:17 -07:00
Cory Benfield
16d5609cc1 Add myself. 2013-05-18 10:39:12 +01:00
Cory Benfield
447d3d2799 Trash debugsupport. 2013-05-18 10:35:54 +01:00
Thomas Waldmann
460251c9ed setup.py: add "six" library to install_requires 2013-05-18 01:16:18 +02:00
Thomas Waldmann
50f6965f2e update docs / changelog about python requirement, add myself to AUTHORS
also added 2 FIXMEs to intro.rst about the debugsupport for python 2.4
that needs to get removed
2013-05-18 01:07:52 +02:00
Thomas Waldmann
07a7d551b5 utils: remove some old py compat code 2013-05-18 00:47:41 +02:00
Thomas Waldmann
d2dbe1031b _markupsafe: remove some py2.4/2.5 compat code 2013-05-18 00:24:05 +02:00
Thomas Waldmann
7d29562ff9 python 3 port: manual fixes, remove 2to3 from setup.py, remove fixers 2013-05-18 00:06:22 +02:00
Thomas Waldmann
e0003555f8 python 3 port: automated changes by a slightly modified python-modernize
(replacing unicode with six.text_type, but not replacing u"" by six.u(""))
2013-05-17 23:52:14 +02:00
Eugene Kalinin
9501718ebb Fixed improperly closed tag in menu example in tricks.rst 2013-05-14 06:59:53 +04:00
John McDonnell
012d0170c4 Allow choice of wrap string in wordwrap filter. 2013-05-07 22:08:42 -04:00
Adam Spiers
08f38a872c Prevent line statements eating newlines (fixes #52) 2013-05-01 18:42:55 +01:00
René Neumann
6b7c0c232f Fix vim syntax: Correctly highlight filters.
`skipwhite` makes only sense in combination with `nextgroup`.
Now filters are correctly highlighted independent of spaces after the
'|'.
2013-04-23 14:50:51 +02:00
Richard Eames
71fc228879 - Allow callable classes to have contextfunction and the like 2013-04-15 23:49:02 -06:00
Richard Eames
ea2890d01b - Testcase 2013-04-15 23:48:48 -06:00
Armin Ronacher
846bdc125c Merge pull request #177 from sakti/patch-1
fix typo swtich -> switch
2013-04-12 16:39:51 -07:00
Armin Ronacher
77bcbfe8da Merge pull request #171 from mgorny/master
Fix jinjaext compatibility with Python 3
2013-04-12 16:39:34 -07:00
Armin Ronacher
d4e54382cb Pessimistic locking for LRU cache. This fixes #8 2013-04-13 00:38:27 +01:00
Armin Ronacher
cc95bf20ce Merge pull request #187 from jet-sun/patch-1
correct typo
2013-04-12 16:19:27 -07:00
Armin Ronacher
05ce2a0554 Merge pull request #193 from mozillazg/patch-1
Fixed an issue about urlize function
2013-04-12 16:18:49 -07:00
Armin Ronacher
c628ece0ec Merge pull request #195 from vergenzt/master
Correct typo in dictsort filter documentation
2013-04-12 16:18:03 -07:00
Tim Vergenz
0a06d880f9 Correct typo in dictsort filter documentation 2013-03-28 13:41:35 -07:00
mozillazg
6644893ecb Fixed an issue about urlize function
When URL startswith 'https://', the return is wrong.
Before:

    >>> urlize('https://github.com/')
    u'<a href="http://https://github.com/">https://github.com/</a>'
After:

    >>> urlize('https://github.com/')
    u'<a href="https://github.com/">https://github.com/</a>'
2013-03-18 14:27:54 +08:00
Jonas Nockert
bdd09dd305 Fixed typos: overriden to overridden 2013-02-23 20:34:47 +01:00
Jet Sun
6e22357d89 correct typo 2013-02-20 15:30:16 -08:00
Kyle Adams
5871ba85dc Fixes #181: Handle memcached errors gracefully. 2013-02-18 13:26:40 -05:00
Sakti Dwi Cahyono
a29f9ddf58 fix typo swtich -> switch 2013-02-15 14:08:45 +07:00
kracekumar
e257b295b8 Update jinja2/filters.py
Fixed spelling mistake in docstring for dictsort
2013-01-15 18:02:49 +05:30
Michał Górny
67c24803e6 Fix jinjaext compatibility with Python 3.
Patch by Arfrever.

Fixes: https://github.com/mitsuhiko/jinja2/issues/115
2013-01-13 22:58:30 +01:00
W. Trevor King
7e912c6dfa Add keep_trailing_newline to configure final endline stripping
This option defaults to False for compatibility with the existing
behaviour.  I've added the option because I expect I won't remember to
keep an extra trailing newline in my templates, and some non-HTML
templates *need* that last newline.

See also:
https://groups.google.com/d/msg/pocoo-libs/6DylMqq1voI/GXTbZJ1Tr-sJ
2013-01-11 08:47:30 -05:00
Mike Chesnut
d329a3e32f adding explicit mention of distribute prerequisite at runtime 2012-12-18 13:52:07 -08:00
Richard
dc99c4e27b Update docs/tricks.rst
Fixing a typo
2012-11-30 23:56:16 -07:00
AquarHEAD L
8e01f54765 update the Docstring of do_truncate, add useful examples 2012-11-26 04:37:13 +08:00
Natan L
63bd806cf1 Fixed typo
'ore' > 'or'
2012-11-22 00:10:41 -08:00
Alex Morega
85b9c8ab39 fix DictLoader uptodate callback 2012-11-18 18:19:47 +01:00
Dimitris Leventeas
aa023e4947 Update docs/templates.rst
Loop (recursive) --> Another loop -> loop(...)
2012-11-01 23:21:32 +01:00
Dmitry Medvinsky
200fe17f1c Fix typo in include documentation 2012-09-21 17:15:38 +04:00
Armin Ronacher
21a2010bf2 Fixed an unicode error after 2to3 2012-09-16 08:30:50 +09:00
Armin Ronacher
9e9cf47c81 Added filesize part to the module compiler. This fixes #131 for 3.3 and later 2012-09-16 08:26:31 +09:00
David Gilman
fd3c9e684f Fix FAQ typo 2012-07-21 01:30:36 -05:00
Kristi Tsukida
e4a74f9b9b Document the {%+ manual disable lstrip_blocks feature 2012-07-12 13:44:54 -07:00
Kristi Tsukida
523efbdf61 fix tests since lstrip_blocks strips comments 2012-07-12 13:38:11 -07:00
Kristi Tsukida
54f7d2ec3b Apply lstrip_blocks to comments (match trim_blocks behavior) 2012-07-12 13:37:21 -07:00
Kristi Tsukida
01d89864d3 Fix lstrip_blocks tests 2012-07-12 13:03:11 -07:00
Kristi Tsukida
fdf8201437 Don't match variable or comment blocks, Use {%+ to disable lstrip_blocks behavior manually 2012-07-12 13:01:42 -07:00
Kristi Tsukida
fb5396605d add tests for lstrip_blocks option 2012-07-12 11:41:39 -07:00
Kristi Tsukida
c5f6531a9a hash lstrip_blocks in lexer cache 2012-07-12 11:41:39 -07:00
Kristi Tsukida
ca927f88b1 clarify lstrip_blocks option 2012-07-10 18:16:28 -07:00
Kristi Tsukida
214bb361c0 document lstrip_blocks 2012-07-10 18:13:52 -07:00
Kristi Tsukida
ea50f7777d remove debug code 2012-07-10 17:29:27 -07:00
Kristi Tsukida
59f33664cf add lstrip_blocks environment setting, fix lexer 2012-07-10 17:13:50 -07:00
Kristi Tsukida
15605a84be lstrip spaces (but not newlines) from block tags 2012-07-10 13:25:38 -07:00
Chase Sterling
dd7fa4aeaa Prevent default filter from throwing UndefinedError when boolean flag is used with StrictUndefined. 2012-07-05 15:43:14 -04:00
Armin Ronacher
6327f79efd Merge pull request #137 from PaulMcMillan/improve_whitespace_docs
Improve whitespace docs to reflect reality.
2012-07-05 00:39:32 -07:00
Paul McMillan
b4188e0d18 Improve whitespace docs to reflect reality.
See also:
https://groups.google.com/d/msg/pocoo-libs/6DylMqq1voI/GXTbZJ1Tr-sJ
2012-07-04 12:00:12 -07:00
cocoatomo
f4dd2a48f8 There is no need to initialize Environment#bytecode_cache. 2012-04-06 02:53:39 +09:00
Christoph Zwerschke
4780c2ce31 Add a note about the else statement. 2012-03-21 16:56:36 +01:00
Christoph Zwerschke
a21f2edfc9 Fix typos. 2012-03-13 16:57:39 -07:00
Ron DuPlain
796ee3ffac Merge pull request #103 from njl/fix-issue-93
Fix to #93, this time respecting whitespace
2012-03-13 16:50:27 -07:00
Ron DuPlain
e5763b358e Distinguish ext folder from ext namespace. 2012-03-13 14:53:15 -07:00
Ned Jackson Lovely
7336b7af6c Fixes issue #77 by adding explanation to docs
Points out that the Django empty is replaced by the
Flask else.
2012-03-12 20:45:08 -04:00
Ned Jackson Lovely
8f0c8ee591 Fix to #93, this time respecting whitespace
Rejigger of title split to respect whitespace, also capitalize follow-on
hyphenated words.
2012-03-12 20:38:06 -04:00
Ron DuPlain
1305cfdaee Merge pull request #78 from SimonSapin/patch-2
Typo fix
2012-03-09 14:29:09 -08:00
Ron DuPlain
220538cc1d Merge pull request #81 from obeattie/docs-fix
Small typo fix to extension docs
2012-03-09 14:26:26 -08:00
Ron DuPlain
a0eabddb1a Merge pull request #95 from florentx/patch-2
Few typos in jinja2.utils
2012-03-09 14:23:22 -08:00
Florent Xicluna
21b624b714 typo 2012-02-05 15:03:12 +01:00
Florent Xicluna
0ec4f763cf Few typos in jinja2.utils 2012-02-05 13:09:15 +01:00
Florent Xicluna
e04e32fac9 Fix the Mako-like environment. 2012-02-05 12:14:08 +01:00
Armin Ronacher
99b22854ea Added changelog entry for #92 and changed LoopContext.End to _last_iteration 2012-01-25 00:42:54 +01:00
Armin Ronacher
ea89feb0d9 Merge pull request #92 from jasonkotenko/master
Fix loop.last memory issue
2012-01-24 15:40:38 -08:00
Jason Kotenko
776567cc4e Fixed loop.last to not consume the entire iterator to determine if this is
the last iteration of the loop.
2012-01-24 14:19:08 -08:00
Florian Apolloner
79c8475f80 fix previous commit, which was kinda nonfunctional 2012-01-18 17:47:54 +01:00
Florian Apolloner
5a25a47996 don't evaluate trans arguments twice. 2012-01-18 17:08:48 +01:00
Armin Ronacher
5145401fe5 Renamed urlescape to urlencode 2012-01-07 17:47:56 +01:00
Armin Ronacher
1d4c6389c9 Reworked implementation of the urlescape filter, made it Python3 compatible, documented it. 2012-01-07 17:46:40 +01:00
Armin Ronacher
f2feb7efcd Normalize to styleguide 2012-01-07 17:28:28 +01:00
Aaron Swartz
c299ff1c65 live up to @mitsuhiko's ridiculous expectations 2012-01-06 20:25:57 -05:00
Aaron Swartz
06a8b1c02b Add urlescape to default filters. 2012-01-06 10:27:36 -05:00
Florian Mounier
33aee12a29 Support included blocks override 2012-01-05 17:06:36 +01:00
Armin Ronacher
80b4fe6159 Merge branch 'master' of github.com:mitsuhiko/jinja2 2011-12-15 11:50:59 +01:00
Armin Ronacher
1161915fd7 Fixed a bug in the i18n extraction option handling and added a silent option. 2011-12-15 11:50:27 +01:00
Oliver Beattie
6e97b06155 Small typo fix to extension docs 2011-12-15 09:47:34 +00:00
Armin Ronacher
7269991b8c Merge pull request #80 from joshmoore/master
Minor typo fix under docs/
2011-12-14 08:17:27 -08:00
jmoore
cd95414e8f Minor type: s/of/or/ 2011-12-14 17:09:29 +01:00
Simon Sapin
52c88fb66a Typo fix 2011-12-03 13:05:08 +01:00
kracekumar
9c198cd5d8 Changed three major types to four major types in nodes.py 2011-11-25 08:26:55 +05:30
Christopher Grebs
7d268bef0e Fixed do_filesizeformat to actually calculate correctly, fixes #59 2011-10-07 22:50:13 +02:00
Armin Ronacher
898975dd5d Added a dict iteration example. This fixes #64 2011-10-06 10:09:31 -04:00
Armin Ronacher
b1b7b0893c Fixed filesizeformat 2011-10-05 09:48:05 +02:00
Armin Ronacher
1898c240cc Added readme 2011-10-03 03:05:52 +02:00
Armin Ronacher
fefea4ab1c Removed tmbundle. Now in mitsuhiko/jinja2-textmate 2011-10-03 03:05:23 +02:00
Dmitry Jemerov
2caef64b6b unused code 2011-09-26 19:06:05 +02:00
Dmitry Jemerov
e3a5d8a937 fix matching typo in tests, restore missing assert 2011-09-26 19:05:46 +02:00
Dmitry Jemerov
4e1bded46c fix typo in test name 2011-09-26 19:05:16 +02:00
Dmitry Jemerov
5c5d061352 couple of typos in comments 2011-09-26 19:04:29 +02:00
Armin Ronacher
345443fdf7 Fixed a typo. 2011-09-26 17:22:22 +02:00
Armin Ronacher
9463850724 Added add_extension method to the public API 2011-09-26 00:41:25 +02:00
Armin Ronacher
c1bc16415b Added GAE debugging snippet 2011-09-25 14:30:12 +02:00
Armin Ronacher
ec9e8eb793 Merge branch 'master' of github.com:mitsuhiko/jinja2 2011-09-13 23:35:34 +02:00
Armin Ronacher
6fa6cb0e12 Improved choice and prefix loaders.
Choice and prefix loaders now dispatch source and template lookup
separately in order to work in combination with module loaders as
advertised.
2011-09-13 23:27:41 +02:00
Armin Ronacher
6336e770b9 Merge pull request #51 from kschuetz/master
Typo fixes in documentation
2011-07-26 12:36:42 -07:00
Kevin Schuetz
c5855506bc added comma 2011-07-26 14:21:52 -05:00
Kevin Schuetz
522af5d96a recieves->receives 2011-07-26 14:17:38 -05:00
Kevin Schuetz
bc542b09e1 calld->called 2011-07-26 14:16:46 -05:00
Kevin Schuetz
30b17d89f4 eached->reached 2011-07-26 14:12:21 -05:00
Armin Ronacher
84ec5156fc Merge pull request #50 from SimonSapin/patch-1
Typo fix ... I think.
2011-07-25 03:09:47 -07:00
Simon Sapin
8b5af89722 Typo fix ... I think. 2011-07-25 00:25:58 -07:00
Armin Ronacher
9b1de00893 master is 2.7-dev 2011-07-24 21:49:07 +02:00
Armin Ronacher
abfbc18822 Added release script 2011-07-24 21:48:29 +02:00
Armin Ronacher
be870827a8 version is now static 2011-07-24 21:46:23 +02:00
Armin Ronacher
397b42e168 Prepairing for a 2.6 release 2011-07-24 21:46:07 +02:00
Armin Ronacher
6e6afa365b Merge pull request #48 from ymirpl/master
"NameError: global name 'code' is not defined" if using byte code cache on Python 2.7.1.
2011-07-12 05:02:23 -07:00
Marcin Mincer
eeea49596a Fixed a bug causing "NameError: global name 'code' is not defined". 2011-07-12 01:59:54 -07:00
Armin Ronacher
4e699a9b1f Merge pull request #47 from mineo/patch-1
Fix a typo
2011-07-07 12:10:31 -07:00
Wieland Hoffmann
06147473cf Fix a typo 2011-07-07 12:09:21 -07:00
Armin Ronacher
8a05e937cc Merge branch 'master' of github.com:mitsuhiko/jinja2 2011-07-07 15:42:55 +02:00
Armin Ronacher
ff115c4e7b Fixed a broken example. This fies #45 2011-07-07 15:42:25 +02:00
Armin Ronacher
b523c93202 Merge pull request #43 from jfinkels/patch-1
fixed typo in documentation: "environmentfilter" -> "evalcontextfilter"
2011-07-05 09:25:39 -07:00
Jeffrey Finkelstein
449ef028e4 fixed typo in documentation: "environmentfilter" -> "evalcontextfilter" 2011-07-01 15:46:54 -07:00
Armin Ronacher
255d702871 Merge pull request #41 from andymckay/master
typo?
2011-06-30 14:42:01 -07:00
Andy McKay
200444922b fix typo 2011-06-30 14:40:05 -07:00
Armin Ronacher
a80d2f560c Merge pull request #39 from failberg/master
Bugfix for list_templates in PackageLoader
2011-06-16 19:13:38 -07:00
Armin Ronacher
1655b4e4c1 Fixed groupby bare integer. This fixes #40 2011-06-17 04:13:00 +02:00
Bryan Berg
bd13945a69 Fix list_modules for PackageLoader 2011-06-13 18:43:11 -07:00
Armin Ronacher
18286b6efb Merge pull request #33 from razamatan/master
jinja.vim subsumes htmljinja.vim
2011-05-24 08:50:55 -07:00
Armin Ronacher
086174cd84 Various tweaks to support bccache on Python 3. This fixes #34 2011-05-24 17:50:08 +02:00
Armin Ronacher
d01d34b1a1 Merge branch 'master' of github.com:mitsuhiko/jinja2 2011-05-24 16:40:38 +02:00
Armin Ronacher
ee352ec21f Added test for mappings. This fixes #35 2011-05-24 16:40:23 +02:00
Armin Ronacher
067879e541 More extensions in jinja debug 2011-05-24 16:40:09 +02:00
Armin Ronacher
e37f697754 Merge pull request #37 from fabiant7t/patch-1
Fixed example of a division with a truncated integer result
2011-05-24 07:33:06 -07:00
Fabian Topfstedt
6ae1285fa5 Fixed example of a division with a truncated integer result (it's // instead of /) 2011-05-22 08:19:12 -07:00
Armin Ronacher
6057afaa6b Merge pull request #36 from afandian/patch-1
Kampala is the capital of Uganda!
2011-05-19 05:01:53 -07:00
Joe Wass
accd062a55 Kampala is the capital of Uganda! Jinja's significant, but not the capital... 2011-05-19 03:58:05 -07:00
Jin Yi
ef30ab56ab jinja.vim subsumes htmljinja.vim 2011-05-13 16:04:20 -07:00
Armin Ronacher
7c97352a4a Merge pull request #30 from sevas/wordwrap-newline
wordwrap filter should use the newline_sequence defined in current Environment
2011-05-07 15:27:10 -07:00
Armin Ronacher
fbfc9d2622 Merge pull request #26 from jek/master
Removes some dead code from self.block lookup path
2011-05-07 15:26:51 -07:00
Armin Ronacher
20a4023b08 Merge pull request #28 from alanhogan/patch-1
Clarity
2011-05-07 15:26:31 -07:00
sevas
218cb64313 wordwrap filter should use the newline_sequence defined in current Environment object 2011-05-01 23:28:25 +02:00
Alan Hogan
02901a8a20 Clarity 2011-04-28 20:18:55 -07:00
jason kirtland
355d96f942 Removed dead code. 2011-04-25 11:19:22 -07:00
Kanak Kshetri
e68d4c6ec1 jinja.el: replace obsolete mumamo-find-possible-chunk with mumamo-quick-chunk-forward . This allows jinja mode to be used with nxhtml mode versions later than 2.07.
Signed-off-by: Armin Ronacher <armin.ronacher@active-4.com>
2011-04-25 16:05:03 +02:00
Armin Ronacher
75ffeb6b02 Catch down errors caused by tb_set_next. This fixes #22 2011-04-18 16:27:14 +02:00
Armin Ronacher
da63262f0e Fixed a test case 2011-03-13 14:33:27 -04:00
Alan Plum
d90f0500cd Fixed filesizeformat filter. It should now conform to the official SI prefixes and use the correct prefixes for sizes greater than base ** 4.
Signed-off-by: Armin Ronacher <armin.ronacher@active-4.com>
2011-02-17 17:06:45 +01:00
Armin Ronacher
4b37694034 Use actual release info 2011-02-06 12:28:29 +01:00
Armin Ronacher
30d14488e7 With number of course. Jinja2.pdf not Jinja.pdf 2011-02-06 12:21:18 +01:00
Armin Ronacher
89f61fdec2 Yay. PDF docs for Jinja2 2011-02-06 12:19:30 +01:00
Armin Ronacher
2a590efdc8 Another reference 2011-01-29 20:29:00 +01:00
Armin Ronacher
c889d326e5 Reference to compile_templates 2011-01-29 20:26:14 +01:00
Armin Ronacher
46844982d9 Added missing references to docs 2011-01-29 20:19:58 +01:00
Armin Ronacher
c6749dc66d Slightly modified headline style 2011-01-24 12:49:56 +01:00
Armin Ronacher
d06dcc0bda Makefile for uploading and stuff 2011-01-24 02:04:48 +01:00
Armin Ronacher
988a04cebb New documentation style go match Flask and Werkzeug better 2011-01-24 02:03:57 +01:00
Armin Ronacher
53278a3238 Damn you Sphinx 2011-01-24 01:16:00 +01:00
Armin Ronacher
d464d0820c Fixed a bug in the documentation tool 2011-01-24 01:14:20 +01:00
Armin Ronacher
3383e1ca37 join now also accepts parameters 2011-01-24 01:13:51 +01:00
Armin Ronacher
a8d2556834 Improved documentation for sum 2011-01-24 01:07:36 +01:00
Armin Ronacher
b7e75b8ea7 sort now also accepts an attribute 2011-01-24 01:05:47 +01:00
Armin Ronacher
dd8afa2204 The sum filter can now sum up attributes 2011-01-24 00:57:58 +01:00
Armin Ronacher
bc56cd25c9 Grammar. 2011-01-15 18:35:45 +01:00
Armin Ronacher
51db6c97e0 No longer segfault on new versions. This fixes #4 2011-01-11 20:53:42 +01:00
Armin Ronacher
5f3d661874 Fixed imports with scoped blocks 2010-12-22 23:22:08 +01:00
Armin Ronacher
9573b663d5 groupby now supports attributes of attributes. This fixes #10 2010-12-21 00:44:34 +01:00
Armin Ronacher
9adf937e4d Updated documentation for operator intercepting 2010-11-29 14:29:00 +01:00
Armin Ronacher
a91953807a Implemented operator intercepting 2010-11-29 13:21:57 +01:00
Armin Ronacher
b6b3c9922a Removed more imports 2010-11-29 13:02:06 +01:00
Armin Ronacher
ded66ec61b Removed unnecessary imports 2010-11-29 13:01:39 +01:00
Armin Ronacher
d9455c186f Fixed a typo and removed a useless backslash 2010-11-29 12:39:11 +01:00
Armin Ronacher
5661726123 Removed unused import 2010-11-29 12:36:18 +01:00
Armin Ronacher
1b6425f158 Traceback support now works with PyPy 2010-11-29 12:24:57 +01:00
Armin Ronacher
7ae5482ac4 Traceback hack now works for pypy 2010-11-29 12:24:03 +01:00
Armin Ronacher
9e5d083268 Should work for cpython and pypy now (if the latter is fixed) 2010-11-29 12:16:17 +01:00
Armin Ronacher
19a23746b0 We cannot fake the descriptor on a tproxy so we have to set _tb_next directly 2010-11-29 12:14:50 +01:00
Armin Ronacher
40c593e5f5 Started work on support for transparent proxies for the debug hack 2010-11-29 10:50:34 +01:00
Armin Ronacher
6a3e95d008 Undefineds now support attribute errors for special attributes. This fixes #6 2010-11-19 13:51:38 +01:00
Ian Lewis
ab014bda66 Changed naked except statements to catch only subclasses of Exception.
Naked except statements catch subclasses of BaseException which
can occur anywhere (i.e. KeyboardInterrupt).

Unexpected issues can occur when the exception happens during the
loading of a module. The python interpreter doesn't know about a
module's failed load and does not remove it from sys.modules. This
is particularly a problem on AppEngine where python will think the
module is loaded but in fact the module load has failed.

See: http://code.google.com/p/googleappengine/issues/detail?id=1409
Signed-off-by: Armin Ronacher <armin.ronacher@active-4.com>
2010-11-07 13:35:08 +01:00
Armin Ronacher
64ff4fa4f5 Merge branch '2.5-maintenance'
Conflicts:
	CHANGES
	setup.py
2010-10-18 14:38:39 +02:00
Armin Ronacher
1116573c11 Re-release of 2.5.4 as 2.5.5 without docs 2010-10-18 14:38:03 +02:00
Armin Ronacher
bb09fb255f Merge branch '2.5-maintenance' 2010-10-17 16:48:55 +02:00
Armin Ronacher
75cd04fd98 Release 2.5.4 as well 2010-10-17 16:48:18 +02:00
Armin Ronacher
cff8e1cd5d Merge branch '2.5-maintenance' 2010-10-17 16:47:13 +02:00
Armin Ronacher
da8d68f1f9 Finally fixed the 64bit segfault on big-endian architectures in non-tracing mode 2010-10-17 16:47:06 +02:00
Armin Ronacher
7b93e7ef53 Fixed extensions not loading properly with overlays 2010-10-17 16:44:19 +02:00
Armin Ronacher
44e1f567a6 master will be 2.6 2010-10-17 16:43:07 +02:00
Armin Ronacher
99d70bd309 Merge branch '2.5-maintenance' 2010-10-17 16:42:32 +02:00
Armin Ronacher
e104f3022e This will be 2.5.4 2010-10-17 16:42:26 +02:00
Armin Ronacher
e5babe89dd Added upload command for docs 2010-10-17 16:37:22 +02:00
Armin Ronacher
d6a2003752 Documentation update. Documentation will become the new Jinja2 website 2010-10-17 16:30:15 +02:00
Armin Ronacher
0e7b9f0bbc Merge branch '2.5-maintenance' 2010-10-17 16:13:02 +02:00
Armin Ronacher
1c5be8e976 Updated setup file for URLs 2010-10-17 16:12:55 +02:00
Armin Ronacher
54a13bce8f Fixed link to git 2010-10-17 16:07:38 +02:00
Armin Ronacher
d811ab5dc7 Changed links to github 2010-10-17 16:07:08 +02:00
Armin Ronacher
91f7fefbcb Merge branch '2.5-maintenance' 2010-10-17 16:04:26 +02:00
Armin Ronacher
a0cc246dff Removed unneeded file 2010-10-17 16:04:19 +02:00
Armin Ronacher
f2cd943c03 Merge branch '2.5-maintenance' 2010-10-17 16:02:23 +02:00
Armin Ronacher
3dd4155f2d Updated ignore files 2010-10-17 16:02:17 +02:00
Armin Ronacher
f55b1a4edf Added README 2010-10-17 15:58:08 +02:00
Armin Ronacher
f858d62138 Updated CHANGES entry for release 2010-10-17 15:56:49 +02:00
Armin Ronacher
613912d137 fixed an operator precedence error introduced in 2.5.2.
Statements like "-foo.bar" had their implicit parentheses applied around
the first part of the expression ("(-foo).bar") instead of the more
correct "-(foo.bar)".
2010-10-17 15:53:59 +02:00
Armin Ronacher
9dc0619d65 Prepare for Jinja 2.5.3 2010-10-17 15:52:57 +02:00
Armin Ronacher
fe22512b21 Unbroke setup.py
--HG--
branch : trunk
2010-08-18 11:14:28 +02:00
Armin Ronacher
8e260d2f3c Merged in fix for Python 3 regarding precisions
--HG--
branch : trunk
2010-08-18 11:13:16 +02:00
Armin Ronacher
c4538a854b Improved message and unbroke 3.x
--HG--
branch : trunk
2010-08-18 11:12:52 +02:00
Armin Ronacher
4603694a92 Preparing for a 2.5.2 release. Fixed an issue with setup.py
--HG--
branch : trunk
2010-08-18 11:10:50 +02:00
Rodrigo Moraes
6cc2b236ea Added benchmark for chameleon/chameleon-genshi.
--HG--
branch : trunk
2010-08-17 12:08:01 -03:00
Ronny Pfannschmidt
e589a3e20e round filter: remove the special case for precission=0 in order to ensure consistent output types on python3
--HG--
branch : trunk
2010-08-17 13:18:41 +02:00
Armin Ronacher
dd0039c9aa tip is 2.6
--HG--
branch : trunk
2010-08-17 12:39:40 +02:00
Armin Ronacher
e3f3bc5cda Added tag 2.5.1 for changeset 7867a9cb933a
--HG--
branch : trunk
2010-08-17 12:39:07 +02:00
Armin Ronacher
2ee64bc402 fixed an issue with unary operators having the wrong precendence.
--HG--
branch : trunk
2010-08-17 12:36:38 +02:00
Armin Ronacher
2613e5ad23 Merged in ronny's fixes for round filter
--HG--
branch : trunk
2010-08-17 12:11:45 +02:00
Armin Ronacher
10c34da7df Documented switch to MarkupSafe
--HG--
branch : trunk
2010-08-17 12:10:27 +02:00
Armin Ronacher
53675ce87c Pulled in code from markupsafe
--HG--
branch : trunk
2010-08-17 11:57:18 +02:00
Armin Ronacher
f9f5f267bf MarkupSafe is now used for the Jinja2 speedups
--HG--
branch : trunk
2010-08-17 11:57:07 +02:00
Ronny Pfannschmidt
b299acb6ce fix the abs filter test
--HG--
branch : trunk
2010-08-17 11:43:06 +02:00
Ronny Pfannschmidt
0d94e08e3d round filter support+test negative precission in the round and use power of 10 instead of multiples
--HG--
branch : trunk
2010-08-17 11:42:45 +02:00
Armin Ronacher
fd72972eb4 Meh. Fixed a typo
--HG--
branch : trunk
2010-08-16 12:13:04 +02:00
Armin Ronacher
3c95532794 Fixed spelling
--HG--
branch : trunk
2010-08-08 22:23:51 +02:00
Armin Ronacher
13203e1de1 Added docs for comparisions
--HG--
branch : trunk
2010-08-08 21:59:29 +02:00
Armin Ronacher
3ca776188b Added anothe test
--HG--
branch : trunk
2010-07-06 12:00:33 +02:00
Armin Ronacher
4cccc22262 Added new testcase
--HG--
branch : trunk
2010-07-06 11:37:45 +02:00
Armin Ronacher
4f77a305df babel extraction can now properly extract newstyle gettext calls.
using the variable `num` in newstyle gettext for something else
than the pluralize count will no longer raise a :exc:`KeyError`.

--HG--
branch : trunk
2010-07-01 12:15:39 +02:00
Armin Ronacher
5a8d49689a Updated rwbench
--HG--
branch : trunk
2010-07-01 12:15:35 +02:00
Armin Ronacher
02ea18a29d We will have a 2.5.1 release
--HG--
branch : trunk
2010-07-01 11:30:42 +02:00
Armin Ronacher
850629f1c3 Fixed the profile.py file and removed a useless newline call
--HG--
branch : trunk
2010-06-06 15:14:55 +02:00
Armin Ronacher
b480418b24 Raised version number in setup.py
--HG--
branch : trunk
2010-06-05 14:41:55 +02:00
Armin Ronacher
9fb60423d3 Documented changes.
--HG--
branch : trunk
2010-06-05 14:41:34 +02:00
Armin Ronacher
ac0c0d08e8 Committed fix for raw testcase.
--HG--
branch : trunk
2010-06-05 14:37:32 +02:00
Armin Ronacher
b525c9374d Added failing testcase for raw.
--HG--
branch : trunk
2010-06-05 14:37:09 +02:00
Armin Ronacher
3351a93bf7 Calls to functions in templates are now intercepted for StopIteration.
Improved performance of macro call slightly.

--HG--
branch : trunk
2010-06-05 14:32:06 +02:00
Armin Ronacher
f60232d52b Updated examples to use Django cached.
--HG--
branch : trunk
2010-06-05 14:31:27 +02:00
Armin Ronacher
53cafcc1ae Added tag 2.5 for changeset 0dd0062a6480
--HG--
branch : trunk
2010-05-29 22:54:16 +02:00
Armin Ronacher
2856c211fa Removed tag 2.5
--HG--
branch : trunk
2010-05-29 22:54:15 +02:00
Armin Ronacher
9512d3274f Tip is 2.5, not 2.4.2
--HG--
branch : trunk
2010-05-29 22:54:06 +02:00
Armin Ronacher
c726d92ece Added tag 2.5 for changeset 3f3eadf15f61
--HG--
branch : trunk
2010-05-29 22:53:39 +02:00
Armin Ronacher
b98dad9808 Added a small improvement for the code generation of newstyle gettext
calls.

--HG--
branch : trunk
2010-05-29 22:31:17 +02:00
Armin Ronacher
a4c7843666 Added a testcase for add_extension
--HG--
branch : trunk
2010-05-29 22:03:29 +02:00
Armin Ronacher
8a3d93ba46 Fixed a typo in the docs
--HG--
branch : trunk
2010-05-29 22:02:03 +02:00
Armin Ronacher
ec25a0c3bb Fixed a bug in add_extension
--HG--
branch : trunk
2010-05-29 22:01:59 +02:00
Armin Ronacher
78efe7401b Added hooks for compilation and generation. This fixes #384
--HG--
branch : trunk
2010-05-29 21:48:24 +02:00
Armin Ronacher
1120b7b0aa Next try for a Python 3 fix
--HG--
branch : trunk
2010-05-29 21:16:35 +02:00
Armin Ronacher
d1ef7e0f43 Fixed a Python 3 bug.
--HG--
branch : trunk
2010-05-29 21:00:44 +02:00
Armin Ronacher
5da3181a8a Removed debug print
--HG--
branch : trunk
2010-05-29 20:58:44 +02:00
Armin Ronacher
ffaa2e7908 it's now possible to register extensions after an environment
was created.

--HG--
branch : trunk
2010-05-29 20:57:16 +02:00
Armin Ronacher
b8892e7b03 Finished support for newstyle gettext translations
--HG--
branch : trunk
2010-05-29 17:58:06 +02:00
Armin Ronacher
4da90349e8 Tip is now 2.5. Started work on newstyle gettext translations.
--HG--
branch : trunk
2010-05-29 17:35:10 +02:00
Armin Ronacher
7db9872700 Next release without pycs
--HG--
branch : trunk
2010-05-23 23:23:44 +02:00
Armin Ronacher
82a2225ac9 Fixed another failing testcase that was never added to the test runner.
Epic fail

--HG--
branch : trunk
2010-05-23 23:14:59 +02:00
Armin Ronacher
2641510691 tip is 2.4.2 dev.
--HG--
branch : trunk
2010-05-23 23:07:32 +02:00
Armin Ronacher
737954909f Version 2.4.2
-------------
(bugfix release, release date to be announced)

improved the sort filter (should have worked like this for a
long time) by adding support for case insensitive searches.
fixed a bug for getattribute constant folding.

--HG--
branch : trunk
2010-05-23 23:07:08 +02:00
Armin Ronacher
5a5ce730ee Fixed a failing testcase. (Error caused by constant folding of undefined
values)

--HG--
branch : trunk
2010-05-23 22:58:28 +02:00
Georg Brandl
93d2df782d Fix unbound local error masked by bare except.
--HG--
branch : trunk
2010-05-23 22:35:53 +02:00
Armin Ronacher
802f4720cd Different name for builtins in Python 3
--HG--
branch : trunk
2010-04-20 19:48:46 +02:00
Armin Ronacher
2ec1d2cd2d tip iis 2.5
--HG--
branch : trunk
2010-04-20 13:46:08 +02:00
Armin Ronacher
389542bdc5 Added tag 2.4.1 for changeset d927a7499531
--HG--
branch : trunk
2010-04-20 13:45:17 +02:00
Armin Ronacher
800ac7f623 fixed an error reporting bug for undefineds.
--HG--
branch : trunk
2010-04-20 13:45:11 +02:00
Armin Ronacher
27387aa54a tip is 2.5
--HG--
branch : trunk
2010-04-13 00:56:34 +02:00
Armin Ronacher
9de932c045 Added tag 2.4 for changeset e3f873a9d3ff
--HG--
branch : trunk
2010-04-13 00:55:38 +02:00
Armin Ronacher
30b39cd4d9 Ready for release.
--HG--
branch : trunk
2010-04-13 00:54:14 +02:00
Armin Ronacher
98dbf5fb1d Improved error message for undefineds
--HG--
branch : trunk
2010-04-12 15:49:59 +02:00
Armin Ronacher
7d29ec6827 extensions have a priority now.
--HG--
branch : trunk
2010-04-12 14:04:35 +02:00
Armin Ronacher
5b3f4dcca2 Added extension ordering, this fixes #376.
--HG--
branch : trunk
2010-04-12 14:04:14 +02:00
Armin Ronacher
4855908121 Undefineds give better hints for None objects now.
--HG--
branch : trunk
2010-04-12 13:51:33 +02:00
Armin Ronacher
2e3c9c7b0a three is the new two
--HG--
branch : trunk
2010-04-10 13:03:46 +02:00
Armin Ronacher
8a672512e7 Fixed a scoping bug that caused the immutable scoping rule to be ignored
in a few edge cases.  This clauses #376.

--HG--
branch : trunk
2010-04-05 18:43:07 +02:00
Armin Ronacher
752ba7f0d9 Added missing reference.
--HG--
branch : trunk
2010-04-05 18:17:27 +02:00
Armin Ronacher
1da23d19ec autoescape no longer is a plain boolean value but can also be a function
to enable or disable autoescaping for certain filenames (or file
extensions for that matter)

--HG--
branch : trunk
2010-04-05 18:11:18 +02:00
Armin Ronacher
cedb482ad1 Added improved documentation to the ContextReference node.
--HG--
branch : trunk
2010-03-24 10:53:22 +01:00
Armin Ronacher
0dbaf39c7d Another documentation string fix.
--HG--
branch : trunk
2010-03-15 10:06:53 +01:00
Armin Ronacher
76ae15ea55 Hopefully fixed EvalContext documentation.
--HG--
branch : trunk
2010-03-15 09:36:47 +01:00
Armin Ronacher
30fda27053 More documentation updates.
--HG--
branch : trunk
2010-03-15 03:06:04 +01:00
Armin Ronacher
e3faeb5e5f Updated copyright. It's 2010!
--HG--
branch : trunk
2010-03-15 02:49:22 +01:00
Armin Ronacher
fe150f3cec Documented autoescaping behavior and eval contexts.
--HG--
branch : trunk
2010-03-15 02:42:41 +01:00
Armin Ronacher
c57959d46b Template to module compilation should work on 3.x now.
--HG--
branch : trunk
2010-03-15 00:54:01 +01:00
Armin Ronacher
f3c66d9252 Fixed a testcase for Python 2.4
--HG--
branch : trunk
2010-03-15 00:48:46 +01:00
Armin Ronacher
d7c765de54 More testcaseeees :)
--HG--
branch : trunk
2010-03-15 00:42:27 +01:00
Armin Ronacher
744bb0a323 Added another testcase and fixed a bug with the volatile scoping.
--HG--
branch : trunk
2010-03-15 00:26:05 +01:00
Armin Ronacher
d3e6bc4119 Added a new testcase for something that is supposed to be a bug.
--HG--
branch : trunk
2010-03-15 00:03:25 +01:00
Armin Ronacher
8346bd7ec3 Biggest change to Jinja since the 1.x migration: added evaluation contexts
which make it possible to keep the ahead of time optimizations and provide
dynamic activation and deactivation of autoescaping and other context
specific features.

--HG--
branch : trunk
2010-03-14 19:43:47 +01:00
Armin Ronacher
12a316bd5c Improved tests and template compilation.
--HG--
branch : trunk
2010-03-12 17:59:51 +01:00
Armin Ronacher
95131f2776 Just in case there is no gc module.
--HG--
branch : trunk
2010-03-12 03:37:03 +01:00
Armin Ronacher
15e69b337c Streamlined code. Removed an unnecessary leftover.
--HG--
branch : trunk
2010-03-12 03:27:33 +01:00
Armin Ronacher
64b08a0a84 added a :class:ModuleLoader that can load templates from
precompiled sources.  The environment now features a method
to compile the templates from a configured loader into a zip
file or folder.

--HG--
branch : trunk
extra : rebase_source : 4824f663e4ff58ca3d2176c65fc1b7494e1f0c43
2010-03-12 03:17:41 +01:00
Georg Brandl
05be95a359 Make the _speedups extension compatible with Python 3.
--HG--
branch : trunk
2010-02-21 17:50:32 +01:00
Georg Brandl
17f5447d9c Fix test in Python 3.2 -- the exception message changed.
--HG--
branch : trunk
2010-02-21 17:49:04 +01:00
Armin Ronacher
d72105faed Merged in 2.3.1 release fixes
--HG--
branch : trunk
2010-02-19 13:40:23 +01:00
Armin Ronacher
dbac319c26 Added tag 2.3.1 for changeset 140c54afc249
--HG--
branch : trunk
2010-02-19 13:37:33 +01:00
Armin Ronacher
30c2d660dc Untagged 2.3.1 and fixed setup.py for a new release
--HG--
branch : trunk
2010-02-19 13:37:28 +01:00
Armin Ronacher
8986f47be4 merged with 2.3-maintenance
--HG--
branch : trunk
2010-02-19 11:10:32 +01:00
Armin Ronacher
549f6b515e Added changelog
--HG--
branch : trunk
2010-02-19 11:09:28 +01:00
Armin Ronacher
9722bf722e Merged 2.3.1 in
--HG--
branch : trunk
2010-02-19 00:01:18 +01:00
Armin Ronacher
2ae59b2837 Added tag 2.3.1 for changeset 53f4dc68cec0
--HG--
branch : trunk
2010-02-18 23:59:57 +01:00
Armin Ronacher
9164d04a5d Merged in changes from 2.3.1
--HG--
branch : trunk
2010-02-17 08:02:52 +01:00
Armin Ronacher
086dc7b5a0 Pushed version number in setup.py for 2.3.1 release.
--HG--
branch : trunk
2010-02-17 08:01:10 +01:00
Armin Ronacher
821a4232be Fixed some tests for python 2.4. Disabled a test for 2.4 that does not work because of a python limitation.
--HG--
branch : trunk
2010-02-17 07:59:38 +01:00
Armin Ronacher
2966f175c5 broke a line into two. (test commit)
--HG--
branch : trunk
2010-02-17 00:52:42 +01:00
Armin Ronacher
ae8a93008c The jdebug file should have a 2010 copyright as well.
--HG--
branch : trunk
2010-02-17 00:30:01 +01:00
Armin Ronacher
1442519b0b Removed unnecessary runtime check. Our 2to3 fixer fixes that
automatically now.

--HG--
branch : trunk
2010-02-17 00:25:14 +01:00
Armin Ronacher
04306791bc Reindented a docstring.
--HG--
branch : trunk
2010-02-17 00:16:07 +01:00
Armin Ronacher
47883d1a1b better wording and test commit.
--HG--
branch : trunk
2010-02-16 23:34:45 +01:00
Armin Ronacher
c2c6351305 Documented the API changes in get_template and select_template.
--HG--
branch : trunk
2010-02-16 17:37:17 +01:00
Armin Ronacher
9165d3ed52 the environment template loading functions now transparently
pass through a template object if it was passed to it.  This
makes it possible to import or extend from a template object
that was passed to the template.

--HG--
branch : trunk
2010-02-16 17:35:59 +01:00
Armin Ronacher
df2907e0ab ported fix for #368 from maintenance branch.
--HG--
branch : trunk
2010-02-11 14:29:47 +01:00
Armin Ronacher
28decdbe96 This fixes #368.
--HG--
branch : trunk
2010-02-11 14:27:23 +01:00
Armin Ronacher
559025a3c0 tip is 2.4
--HG--
branch : trunk
2010-02-10 02:23:56 +01:00
Armin Ronacher
840a59cb04 Added tag 2.3 for changeset 2eb624b634a6
--HG--
branch : trunk
2010-02-10 02:19:39 +01:00
Armin Ronacher
d9599c8904 Untagged and added python 3 category.
--HG--
branch : trunk
2010-02-10 02:19:17 +01:00
Armin Ronacher
148058a65e Added tag 2.3 for changeset be1b1d6ac4fc
--HG--
branch : trunk
2010-02-10 02:17:46 +01:00
Armin Ronacher
01aa705ab4 Ready for release
--HG--
branch : trunk
2010-02-10 02:17:35 +01:00
Armin Ronacher
1540b2bae3 Broke a test for 2.x :)
--HG--
branch : trunk
2010-02-10 02:13:51 +01:00
Armin Ronacher
eb43b12f81 Added Python 3 section to the documentation.
--HG--
branch : trunk
2010-02-10 02:10:48 +01:00
Armin Ronacher
0045216c9e Documentation recommends distribute now.
--HG--
branch : trunk
2010-02-10 02:06:06 +01:00
Armin Ronacher
6eb17fc24b ALL TESTS PASS!
--HG--
branch : trunk
2010-02-10 02:02:31 +01:00
Armin Ronacher
0d242be185 Down to 7 failures for Python 3. We're onto something.
--HG--
branch : trunk
2010-02-10 01:35:13 +01:00
Armin Ronacher
acbd408b99 Added comment to why __unicode__ goes after __str__.
--HG--
branch : trunk
2010-02-10 00:07:43 +01:00
Armin Ronacher
790b8a897c Approaching python3 compatibility
--HG--
branch : trunk
2010-02-10 00:05:46 +01:00
Armin Ronacher
b36ddc9a97 Removed old testsuite.
--HG--
branch : trunk
2010-02-09 21:27:54 +01:00
Armin Ronacher
9d8ff9e497 Removed useless prints.
--HG--
branch : trunk
2010-02-09 21:27:14 +01:00
Armin Ronacher
3bfd760b6e Added doctests, hooked up all tests. Yay!
--HG--
branch : trunk
2010-02-09 21:25:44 +01:00
Armin Ronacher
1fb4269bd8 Rest of tests ported, just need to hook up doctests now.
--HG--
branch : trunk
2010-02-09 21:14:16 +01:00
Armin Ronacher
644a281d69 Added the security tests.
--HG--
branch : trunk
2010-02-09 18:06:32 +01:00
Armin Ronacher
fb2295a96c Fixed some tests, added syntax test.
--HG--
branch : trunk
2010-02-09 17:21:19 +01:00
Armin Ronacher
c608fb81d3 Halftime, lexer and parser tests added.
--HG--
branch : trunk
2010-02-09 17:13:30 +01:00
Armin Ronacher
10f4bcc8f5 And import tests :)
--HG--
branch : trunk
2010-02-09 16:52:49 +01:00
Armin Ronacher
210824463a Added inheritance tests.
--HG--
branch : trunk
2010-02-09 16:48:10 +01:00
Armin Ronacher
41d6f71c69 Added tests for the test functions (the jinja ones ^^)
--HG--
branch : trunk
2010-02-09 16:43:12 +01:00
Armin Ronacher
4254936336 Added loader tests.
--HG--
branch : trunk
2010-02-09 16:35:08 +01:00
Armin Ronacher
ade4737dd2 Ported for tests
--HG--
branch : trunk
2010-02-09 16:15:09 +01:00
Armin Ronacher
7af781c446 Started working on unittest powered testsuite.
--HG--
branch : trunk
2010-02-09 16:05:08 +01:00
Armin Ronacher
0faa861cae Propably delaying release for better python 3 support. Started working on
that.

--HG--
branch : trunk
2010-02-09 15:04:51 +01:00
Armin Ronacher
0319c665fe experimental Python 3 support.
--HG--
branch : trunk
2010-02-09 02:09:10 +01:00
Armin Ronacher
656d5e7c31 Some tiny documentation fixes (unicode -> Unicode)
--HG--
branch : trunk
2010-02-09 01:31:47 +01:00
Armin Ronacher
88dc32cb4b PrefixLoader raises correct error message now. This fixes #358.
--HG--
branch : trunk
2010-02-09 01:27:57 +01:00
Armin Ronacher
9b4cc9ff08 added with-statement extension.
--HG--
branch : trunk
2010-02-07 03:55:15 +01:00
Armin Ronacher
8e64adfc05 Improved test invokation. Picks up doctests within Jinja now, changed
doctests that just show usage that would not work on their own so that
they are standard code blocks now and do not disturb testing.

--HG--
branch : trunk
2010-02-07 02:00:11 +01:00
Armin Ronacher
92622e9145 Further error message improvement, this time for #341.
--HG--
branch : trunk
2010-02-07 01:27:47 +01:00
Armin Ronacher
5d659dbe62 Fixed bug in a testcase.
--HG--
branch : trunk
2010-02-07 01:27:34 +01:00
Armin Ronacher
1ef7703cdc Fixed #367 by improving the documentation.
--HG--
branch : trunk
2010-02-06 23:33:11 +01:00
Armin Ronacher
7fd4ad638c Added a testcase for #363. This bug was fixed along the way.
--HG--
branch : trunk
2010-02-06 19:01:58 +01:00
Armin Ronacher
4ac4bdf21c Documentation no longer mentiones "no multiple inheritance" support. that
just confuses people.

--HG--
branch : trunk
2010-02-06 18:02:13 +01:00
Armin Ronacher
890dac016a Fixed typo in documentation.
--HG--
branch : trunk
2010-02-06 16:36:52 +01:00
Armin Ronacher
531578d5aa added support for translator comments if extracted via babel.
--HG--
branch : trunk
2010-02-06 16:34:54 +01:00
Armin Ronacher
ac7adf2e1e Raise version number.
--HG--
branch : trunk
2010-02-06 15:30:44 +01:00
Armin Ronacher
e614e88744 implicit tuple expressions can no longer be totally empty.
This change makes ``{% if %}...{% endif %}`` a syntax error
now. (#364)

--HG--
branch : trunk
2010-02-06 15:04:46 +01:00
Armin Ronacher
5dcb724c92 greatly improved error message reporting. This fixes #339
--HG--
branch : trunk
extra : rebase_source : d8f677273490fa73d5603b68478fa3b54f60ccb9
2010-02-06 14:01:26 +01:00
Armin Ronacher
d9ea26e79f Improved finalize documentation.
--HG--
branch : trunk
2010-01-24 14:29:26 +01:00
Armin Ronacher
55494e4b40 It's a new year
--HG--
branch : trunk
2010-01-22 09:41:48 +01:00
Armin Ronacher
ef18944317 More correct fix for 380. The only thing that is part of the outer scope
is the name of the thing to call.  Though because it will never be able to
track store nodes, the one before should not do harm either.

--HG--
branch : trunk
2010-01-14 01:26:40 +01:00
Armin Ronacher
e0016f5c62 fixed a problem with having call blocks in outer scopes that
have an argument that is also used as local variable in an
inner frame [#360].

--HG--
branch : trunk
2010-01-14 01:20:46 +01:00
Armin Ronacher
a586989948 Just to be on the sure side with that compiler optimization magic
--HG--
branch : trunk
2010-01-14 00:59:31 +01:00
Armin Ronacher
7e40df0f7a Fixed the choice include tests.
--HG--
branch : trunk
2010-01-14 00:54:47 +01:00
Armin Ronacher
31bbd9e34d include tags are now able to select between multiple templates
and take the first that exists, if a list of templates is
given.

--HG--
branch : trunk
2010-01-14 00:41:30 +01:00
Georg Brandl
95632c4dae Fix typos and one extra import.
--HG--
branch : trunk
2009-11-22 18:35:18 +01:00
Armin Ronacher
2f0d659172 Reverted [73b04625ab54]. The old behavior is the new behavior, the other
is not consistenly implementable.

--HG--
branch : trunk
2009-10-26 11:53:27 +01:00
Armin Ronacher
1965e31075 Shortcut for the if inner visit for empty branches.
--HG--
branch : trunk
2009-10-25 13:03:08 +01:00
Armin Ronacher
6e249a0c09 Automated merge with ssh://team@pocoo.org/jinja2-main
--HG--
branch : trunk
2009-10-25 12:46:41 +01:00
Armin Ronacher
74230e6a38 Fixed a scoping bug that was introduced in the development version and was
triggered by multiple layers of local variables not tracked properly in if
statements.

--HG--
branch : trunk
2009-10-25 12:46:31 +01:00
Georg Brandl
79cc8d1640 Fix typo.
--HG--
branch : trunk
2009-10-19 21:17:53 +02:00
Armin Ronacher
2b48839fb6 added a deprecation warning for a variable assignment, scope bug
that exists since 2.0, code could depend on.  See :ref:`jinja-scoping-bug`
for more information on this problem.

Tip is 2.3 as this will be the next release (will happen soon!)

--HG--
branch : trunk
2009-09-18 19:32:46 +02:00
Armin Ronacher
f1c421d6d9 fixes issue with code generator that causes unbound variables
to be generated if set was used in if-blocks.

--HG--
branch : trunk
2009-09-17 00:48:41 +02:00
Armin Ronacher
c4fc031bbc Tip is 2.3
--HG--
branch : trunk
2009-09-14 14:59:18 -07:00
Armin Ronacher
baff55676c Added tag 2.2.1 for changeset b987be13b8f6
--HG--
branch : trunk
2009-09-14 14:58:16 -07:00
Armin Ronacher
9e6400e513 fixes some smaller problems for Jinja2 on Jython.
--HG--
branch : trunk
2009-09-14 14:58:01 -07:00
Armin Ronacher
e7c72bc235 Made the lru cache more robust.
--HG--
branch : trunk
2009-09-14 12:20:33 -07:00
Armin Ronacher
b404439a29 Tiny improvement for the loop hack. Implemented it in a way that the
frame is not modified in the macro body generator.

--HG--
branch : trunk
2009-09-13 15:56:58 -07:00
Armin Ronacher
4ef9234b32 Clarified copyrights.
--HG--
branch : trunk
2009-09-13 10:54:37 -07:00
Armin Ronacher
237f01be58 Fixed the install docs.
--HG--
branch : trunk
2009-09-13 10:35:54 -07:00
Armin Ronacher
a93df48029 speedup extension is now disabled by default (added message) and fixed a
line in the docs.

--HG--
branch : trunk
2009-09-13 10:26:39 -07:00
Armin Ronacher
98c1fca6af Improved wording in the CHANGES file.
--HG--
branch : trunk
2009-09-13 00:46:59 -07:00
Armin Ronacher
7442879f11 Added tag 2.2 for changeset f20ea8e724a0
--HG--
branch : trunk
2009-09-13 00:30:13 -07:00
206 changed files with 27687 additions and 17006 deletions

View File

@ -0,0 +1,17 @@
{
"name": "pallets/jinja",
"image": "mcr.microsoft.com/devcontainers/python:3",
"customizations": {
"vscode": {
"settings": {
"python.defaultInterpreterPath": "${workspaceFolder}/.venv",
"python.terminal.activateEnvInCurrentTerminal": true,
"python.terminal.launchArgs": [
"-X",
"dev"
]
}
}
},
"onCreateCommand": ".devcontainer/on-create-command.sh"
}

View File

@ -0,0 +1,17 @@
#!/bin/bash
set -e
# Install uv if not already installed
if ! command -v uv &> /dev/null; then
echo "Installing uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.cargo/bin:$PATH"
fi
# Create venv using uv and install dependencies
echo "Creating virtual environment and installing dependencies..."
uv sync
# Install pre-commit hooks
echo "Installing pre-commit hooks..."
pre-commit install --install-hooks

13
.editorconfig Normal file
View File

@ -0,0 +1,13 @@
root = true
[*]
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
charset = utf-8
max_line_length = 88
[*.{css,html,js,json,jsx,scss,ts,tsx,yaml,yml}]
indent_size = 2

27
.github/ISSUE_TEMPLATE/bug-report.md vendored Normal file
View File

@ -0,0 +1,27 @@
---
name: Bug report
about: Report a bug in Jinja (not other projects which depend on Jinja)
---
<!--
This issue tracker is a tool to address bugs in Jinja itself. Please use
GitHub Discussions or the Pallets Discord for questions about your own code.
Replace this comment with a clear outline of what the bug is.
-->
<!--
Describe how to replicate the bug.
Include a minimal reproducible example that demonstrates the bug.
Include the full traceback if there was an exception.
-->
<!--
Describe the expected behavior that should have happened but didn't.
-->
Environment:
- Python version:
- Jinja version:

8
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Questions on Discussions
url: https://github.com/pallets/jinja/discussions/
about: Ask questions about your own code on the Discussions tab.
- name: Questions on Chat
url: https://discord.gg/pallets
about: Ask questions about your own code on our Discord chat.

View File

@ -0,0 +1,15 @@
---
name: Feature request
about: Suggest a new feature for Jinja
---
<!--
Replace this comment with a description of what the feature should do.
Include details such as links to relevant specs or previous discussions.
-->
<!--
Replace this comment with an example of the problem which this feature
would resolve. Is this problem solvable without changes to Jinja, such
as by subclassing or using an extension?
-->

25
.github/pull_request_template.md vendored Normal file
View File

@ -0,0 +1,25 @@
<!--
Before opening a PR, open a ticket describing the issue or feature the
PR will address. An issue is not required for fixing typos in
documentation, or other simple non-code changes.
Replace this comment with a description of the change. Describe how it
addresses the linked ticket.
-->
<!--
Link to relevant issues or previous PRs, one per line. Use "fixes" to
automatically close an issue.
fixes #<issue number>
-->
<!--
Ensure each step in CONTRIBUTING.rst is complete, especially the following:
- Add tests that demonstrate the correct behavior of the change. Tests
should fail without the change.
- Add or update relevant docs, in the docs folder and in code.
- Add an entry in CHANGES.rst summarizing the change and linking to the issue.
- Add `.. versionchanged::` entries in any relevant code docs.
-->

24
.github/workflows/lock.yaml vendored Normal file
View File

@ -0,0 +1,24 @@
name: Lock inactive closed issues
# Lock closed issues that have not received any further activity for two weeks.
# This does not close open issues, only humans may do that. It is easier to
# respond to new issues with fresh examples rather than continuing discussions
# on old issues.
on:
schedule:
- cron: '0 0 * * *'
permissions:
issues: write
pull-requests: write
discussions: write
concurrency:
group: lock
jobs:
lock:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@1bf7ec25051fe7c00bdd17e6a7cf3d7bfb7dc771 # v5.0.1
with:
issue-inactive-days: 14
pr-inactive-days: 14
discussion-inactive-days: 14

25
.github/workflows/pre-commit.yaml vendored Normal file
View File

@ -0,0 +1,25 @@
name: pre-commit
on:
pull_request:
push:
branches: [main, stable]
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v6.1.0
with:
enable-cache: true
prune-cache: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
id: setup-python
with:
python-version-file: pyproject.toml
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ hashFiles('pyproject.toml', '.pre-commit-config.yaml') }}
- run: uv run --locked --group pre-commit pre-commit run --show-diff-on-failure --color=always --all-files
- uses: pre-commit-ci/lite-action@5d6cc0eb514c891a40562a58a8e71576c5c7fb43 # v1.1.0
if: ${{ !cancelled() }}

47
.github/workflows/publish.yaml vendored Normal file
View File

@ -0,0 +1,47 @@
name: Publish
on:
push:
tags: ['*']
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v6.1.0
with:
enable-cache: true
prune-cache: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version-file: pyproject.toml
- run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
- run: uv build
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
path: ./dist
create-release:
needs: [build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
- name: create release
run: >
gh release create --draft --repo ${{ github.repository }}
${{ github.ref_name }} artifact/*
env:
GH_TOKEN: ${{ github.token }}
publish-pypi:
needs: [build]
environment:
name: publish
url: https://pypi.org/project/Jinja2/${{ github.ref_name }}
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
- uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
with:
packages-dir: artifact/

49
.github/workflows/tests.yaml vendored Normal file
View File

@ -0,0 +1,49 @@
name: Tests
on:
pull_request:
paths-ignore: ['docs/**', 'README.md']
push:
branches: [main, stable]
paths-ignore: ['docs/**', 'README.md']
jobs:
tests:
name: ${{ matrix.name || matrix.python }}
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
strategy:
fail-fast: false
matrix:
include:
- {python: '3.13'}
- {name: Windows, python: '3.13', os: windows-latest}
- {name: Mac, python: '3.13', os: macos-latest}
- {python: '3.12'}
- {python: '3.11'}
- {python: '3.10'}
- {name: PyPy, python: 'pypy-3.11', tox: pypy3.11}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v6.1.0
with:
enable-cache: true
prune-cache: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.python }}
- run: uv run --locked tox run -e ${{ matrix.tox || format('py{0}', matrix.python) }}
typing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v6.1.0
with:
enable-cache: true
prune-cache: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version-file: pyproject.toml
- name: cache mypy
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ./.mypy_cache
key: mypy|${{ hashFiles('pyproject.toml') }}
- run: uv run --locked tox run -e typing

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
.idea/
.vscode/
__pycache__/
dist/
.coverage*
htmlcov/
.tox/
docs/_build/

View File

@ -1,9 +0,0 @@
^instance$
^instance/
^jinja2/.*\.so$
^docs/_build
^(build|dist|Jinja2\.egg-info)/
\.py[co]$
\.DS_Store$
^env/
^py3k/

View File

@ -1,4 +0,0 @@
38b9483b8ce7c7e92b6f9d03e75017105c2d7965 2.0rc1
344f2e5078d202663a08b50cf3a5f44da2a2cb54 2.0
bac88fe8bc0e50b321a04eea038ed4542c43a62f 2.1
ac0fc30f7b5ffca59769c5d9ed78f50596868af8 2.1.1

18
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,18 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 76e47323a83cd9795e4ff9a1de1c0d2eef610f17 # frozen: v0.11.11
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 648bdbfd6bb1a82f132ecc2c666e0d1b2e4b0d94 # frozen: 0.7.8
hooks:
- id: uv-lock
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0
hooks:
- id: check-merge-conflict
- id: debug-statements
- id: fix-byte-order-marker
- id: trailing-whitespace
- id: end-of-file-fixer

10
.readthedocs.yaml Normal file
View File

@ -0,0 +1,10 @@
version: 2
build:
os: ubuntu-24.04
tools:
python: '3.13'
commands:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
- uv run --group docs sphinx-build -W -b dirhtml docs $READTHEDOCS_OUTPUT/html

31
AUTHORS
View File

@ -1,31 +0,0 @@
Jinja is written and maintained by the Jinja Team and various
contributors:
Lead Developer:
- Armin Ronacher <armin.ronacher@active-4.com>
Developers:
- Christoph Hack
- Georg Brandl
Contributors:
- Bryan McLemore
- Mickaël Guérin <kael@crocobox.org>
- Cameron Knight
- Lawrence Journal-World.
- David Cramer
Patches and suggestions:
- Ronny Pfannschmidt
- Axel Böhm
- Alexey Melchakov
- Bryan McLemore
- Clovis Fabricio (nosklo)
- Cameron Knight
- Peter van Dijk (Habbie)
- Stefan Ebner
- Rene Leonhardt

114
CHANGES
View File

@ -1,114 +0,0 @@
Jinja2 Changelog
================
Version 2.2
-----------
(codename Kong, released on September 13th 2009)
- Include statements can now be marked with ``ignore missing`` to skip
non existing templates.
- Priority of `not` raised. It's now possible to write `not foo in bar`
as an alias to `foo not in bar` like in python. Previously the grammar
required parentheses (`not (foo in bar)`) which was odd.
- Fixed a bug that caused syntax errors when defining macros or using the
`{% call %}` tag inside loops.
- Fixed a bug in the parser that made ``{{ foo[1, 2] }}`` impossible.
- Made it possible to refer to names from outer scopes in included templates
that were unused in the callers frame (#327)
- Fixed a bug that caused internal errors if names where used as iteration
variable and regular variable *after* the loop if that variable was unused
*before* the loop. (#331)
- Added support for optional `scoped` modifier to blocks.
- Added support for line-comments.
- Added the `meta` module.
- Renamed (undocumented) attribute overlay to overlayed on the environment
because it was clashing with a method of the same name. The new attribute
is called "overlayed".
Version 2.1.1
-------------
(Bugfix release)
- Fixed a translation error caused by looping over empty recursive loops.
Version 2.1
-----------
(codename Yasuzō, released on November 23rd 2008)
- fixed a bug with nested loops and the special loop variable. Before the
change an inner loop overwrote the loop variable from the outer one after
iteration.
- fixed a bug with the i18n extension that caused the explicit pluralization
block to look up the wrong variable.
- fixed a limitation in the lexer that made ``{{ foo.0.0 }}`` impossible.
- index based subscribing of variables with a constant value returns an
undefined object now instead of raising an index error. This was a bug
caused by eager optimizing.
- the i18n extension looks up `foo.ugettext` now followed by `foo.gettext`
if an translations object is installed. This makes dealing with custom
translations classes easier.
- fixed a confusing behavior with conditional extending. loops were partially
executed under some conditions even though they were not part of a visible
area.
- added `sort` filter that works like `dictsort` but for arbitrary sequences.
- fixed a bug with empty statements in macros.
- implemented a bytecode cache system. (:ref:`bytecode-cache`)
- the template context is now weakref-able
- inclusions and imports "with context" forward all variables now, not only
the initial context.
- added a cycle helper called `cycler`.
- added a joining helper called `joiner`.
- added a `compile_expression` method to the environment that allows compiling
of Jinja expressions into callable Python objects.
- fixed an escaping bug in urlize
Version 2.0
-----------
(codename jinjavitus, released on July 17th 2008)
- the subscribing of objects (looking up attributes and items) changed from
slightly. It's now possible to give attributes or items a higher priority
by either using dot-notation lookup or the bracket syntax. This also
changed the AST slightly. `Subscript` is gone and was replaced with
:class:`~jinja2.nodes.Getitem` and :class:`~jinja2.nodes.Getattr`.
For more information see :ref:`the implementation details <notes-on-subscriptions>`.
- added support for preprocessing and token stream filtering for extensions.
This would allow extensions to allow simplified gettext calls in template
data and something similar.
- added :meth:`jinja2.environment.TemplateStream.dump`.
- added missing support for implicit string literal concatenation.
``{{ "foo" "bar" }}`` is equivalent to ``{{ "foobar" }}``
- `else` is optional for conditional expressions. If not given it evaluates
to `false`.
- improved error reporting for undefined values by providing a position.
- `filesizeformat` filter uses decimal prefixes now per default and can be
set to binary mode with the second parameter.
- fixed bug in finalizer
Version 2.0rc1
--------------
(no codename, released on June 9th 2008)
- first release of Jinja2

1072
CHANGES.rst Normal file

File diff suppressed because it is too large Load Diff

31
LICENSE
View File

@ -1,31 +0,0 @@
Copyright (c) 2009 by the Jinja Team, see AUTHORS for more details.
Some rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* The names of the contributors may not be used to endorse or
promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

28
LICENSE.txt Normal file
View File

@ -0,0 +1,28 @@
Copyright 2007 Pallets
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,7 +0,0 @@
include MANIFEST.in Makefile CHANGES LICENSE AUTHORS TODO ez_setup.py
recursive-include docs *
recursive-include tests *
recursive-include ext *
recursive-include artwork *
recursive-include examples *
recursive-exclude docs/_build/doctrees *

View File

@ -1,11 +0,0 @@
test:
cd tests; nosetests -v
2to3:
rm -rf py3k
mkdir py3k
cp -R jinja2 py3k
2to3 jinja2 > py3k/convert.patch
cd py3k; patch -p0 < convert.patch
.PHONY: test

59
README.md Normal file
View File

@ -0,0 +1,59 @@
<div align="center"><img src="https://raw.githubusercontent.com/pallets/jinja/refs/heads/stable/docs/_static/jinja-name.svg" alt="" height="150"></div>
# Jinja
Jinja is a fast, expressive, extensible templating engine. Special
placeholders in the template allow writing code similar to Python
syntax. Then the template is passed data to render the final document.
It includes:
- Template inheritance and inclusion.
- Define and import macros within templates.
- HTML templates can use autoescaping to prevent XSS from untrusted
user input.
- A sandboxed environment can safely render untrusted templates.
- AsyncIO support for generating templates and calling async
functions.
- I18N support with Babel.
- Templates are compiled to optimized Python code just-in-time and
cached, or can be compiled ahead-of-time.
- Exceptions point to the correct line in templates to make debugging
easier.
- Extensible filters, tests, functions, and even syntax.
Jinja's philosophy is that while application logic belongs in Python if
possible, it shouldn't make the template designer's job difficult by
restricting functionality too much.
## In A Nutshell
```jinja
{% extends "base.html" %}
{% block title %}Members{% endblock %}
{% block content %}
<ul>
{% for user in users %}
<li><a href="{{ user.url }}">{{ user.username }}</a></li>
{% endfor %}
</ul>
{% endblock %}
```
## Donate
The Pallets organization develops and supports Jinja and other popular
packages. In order to grow the community of contributors and users, and
allow the maintainers to devote more time to the projects, [please
donate today][].
[please donate today]: https://palletsprojects.com/donate
## Contributing
See our [detailed contributing documentation][contrib] for many ways to
contribute, including reporting issues, requesting features, asking or answering
questions, and making PRs.
[contrib]: https://palletsprojects.com/contributing/

39
TODO
View File

@ -1,39 +0,0 @@
Todo Before Release
===================
This has to be implemented before the release:
Pull Attributes Onces
---------------------
Imagine the following template::
{% if foo.bar %}
{{ baz(foo.bar) }}
{% endif %}
Problem with that is that it compiles to this::
if environment.subscribe(l_foo, 'bar'):
if 0: yield None
yield u'\n %s\n' % (
l_baz(environment.subscribe(l_foo, 'bar')),
)
As `environment.subscribe` is more expensive then regular attribute lookups
(it tries getitem/getattr and in sandbox mode also permissions) multiple
lookups with the same parameters in the same scope should get local aliases.
The result we have is that one::
t1 = environment.subscribe(l_foo, 'bar')
if t1:
if 0: yield None
yield u'\n %s\n' % (
l_baz(t1),
)
However that should only happen if the attribute is accessed multiple times
unlike locals and filters/tests which are always pulled. We're not doing that
for filters/tests/locals as nested scopes may access it and testing is too
complicated for the tiny performance improvement but easy for attribute
lookups, keeping the complexity of the whole thing in mind.

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 18 KiB

View File

@ -1,75 +1,19 @@
# Makefile for Sphinx documentation
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html web pickle htmlhelp latex changes linkcheck
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " changes to make an overview over all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
clean:
-rm -rf _build/*
.PHONY: help Makefile
html:
mkdir -p _build/html _build/doctrees
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html
@echo
@echo "Build finished. The HTML pages are in _build/html."
pickle:
mkdir -p _build/pickle _build/doctrees
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle
@echo
@echo "Build finished; now you can process the pickle files"
json:
mkdir -p _build/json _build/doctrees
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) _build/json
@echo
@echo "Build finished; now you can process the json files"
web: pickle
htmlhelp:
mkdir -p _build/htmlhelp _build/doctrees
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in _build/htmlhelp."
latex:
mkdir -p _build/latex _build/doctrees
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex
@echo
@echo "Build finished; the LaTeX files are in _build/latex."
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
"run these through (pdf)latex."
changes:
mkdir -p _build/changes _build/doctrees
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) _build/changes
@echo
@echo "The overview file is in _build/changes."
linkcheck:
mkdir -p _build/linkcheck _build/doctrees
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) _build/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in _build/linkcheck/output.txt."
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

11
docs/_static/jinja-icon.svg vendored Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 500 500" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<rect id="Icon" x="0" y="0" width="500" height="500" style="fill:none;"/>
<clipPath id="_clip1">
<rect x="0" y="0" width="500" height="500"/>
</clipPath>
<g clip-path="url(#_clip1)">
<path d="M491.941,72.796l-1.81,-0c-88.724,29.526 -204.909,29.526 -237.199,28.989l-29.877,-0.536c-88.119,-3.222 -133.085,-37.043 -211.849,-72.206c-5.432,-2.416 -11.77,1.61 -11.166,7.247c0.604,19.327 5.734,100.39 66.392,121.596c2.112,0.805 4.526,1.61 6.639,2.147c3.018,0.537 4.225,2.953 4.828,4.563l5.131,15.837c0.905,3.758 3.621,6.979 6.639,6.979l5.13,0c4.527,0 8.148,3.221 8.45,7.248l-0,15.3c-0,1.61 -1.509,2.953 -3.32,2.953l-38.929,-0c-3.622,-0 -6.64,2.684 -6.64,5.905l0,23.89c0,3.221 3.018,5.905 6.64,5.905l38.929,-0c1.811,-0 3.32,1.342 3.32,2.953l-0,6.442c-0,1.61 -1.509,2.952 -3.32,2.952l-38.929,0c-3.622,0.269 -6.338,2.685 -6.338,5.906l0,23.889c0,2.685 2.414,5.637 5.13,5.637l40.439,0c1.811,0 3.32,1.342 3.32,2.953l-0,157.027c-0,8.053 7.544,14.764 16.597,14.764l27.462,-0c9.054,-0 16.598,-6.711 16.598,-14.764l0,-157.027c0,-1.611 1.509,-2.953 3.32,-2.953l169.6,-0.268c1.811,-0 3.32,1.342 3.32,2.952l-0,157.833c-0,8.053 7.544,14.764 16.598,14.764l27.462,-0c9.053,-0 16.598,-6.711 16.598,-14.764l-0,-158.101c-0,-1.611 1.508,-2.953 3.319,-2.953c0,0 42.249,-0.268 42.853,-0.537c1.811,-1.073 3.018,-2.952 3.018,-5.1l-0,-23.621c-0,-3.221 -3.018,-5.905 -6.941,-5.905l-41.948,-0l0,-0.269l-0.301,0l-0,-8.857c-0,-1.611 1.508,-2.953 3.319,-2.953l38.93,-0c3.621,-0 6.639,-2.684 6.639,-5.905l-0,-23.89c-0,-3.221 -3.018,-5.905 -6.639,-5.905l-38.93,-0c-1.811,-0 -3.319,-1.343 -3.319,-2.953l-0,-15.3c-0,-3.758 3.621,-7.248 8.449,-7.248l5.131,0c3.621,0 5.733,-3.489 6.639,-6.979l5.13,-15.837c0.604,-2.147 2.716,-4.026 5.13,-4.831c38.93,-8.59 54.924,-34.09 68.203,-74.085l-0,-0.268c1.508,-10.2 -5.432,-12.079 -7.847,-12.616Zm-150.89,114.08l0,23.352c0,3.221 -2.112,5.637 -4.828,5.637l-54.321,0c-2.716,0 -4.828,-2.416 -4.828,-5.637l-0,-23.352c-0,-2.953 2.112,-5.637 4.828,-5.637l54.321,-0c2.414,0.268 4.828,2.684 4.828,5.637Zm-111.96,-0l-0,23.352c-0,2.953 -2.112,5.637 -4.828,5.637l-54.321,0c-2.716,0 -4.828,-2.416 -4.828,-5.637l-0,-23.352c-0,-2.953 2.112,-5.637 4.828,-5.637l54.321,-0c2.414,0.268 4.828,2.684 4.828,5.637Z" style="fill:#7e0c1b;fill-rule:nonzero;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

11
docs/_static/jinja-logo.svg vendored Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 500 500" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<rect id="Logo" x="0" y="0" width="500" height="500" style="fill:none;"/>
<path id="Box" d="M500,50l0,400c0,27.596 -22.404,50 -50,50l-400,0c-27.596,0 -50,-22.404 -50,-50l0,-400c0,-27.596 22.404,-50 50,-50l400,0c27.596,0 50,22.404 50,50Z" style="fill:url(#_Linear1);"/>
<path id="Shadow" d="M500,246.897l0,203.103c0,27.596 -22.404,50 -50,50l-164.98,0l-119.852,-119.852c1.802,1.562 4.252,2.533 6.921,2.533l16.477,0c5.432,0 9.959,-4.026 9.959,-8.858l-0,-94.216c-0,-0.966 0.905,-1.772 1.992,-1.772l101.76,-0.161c1.086,0 1.992,0.806 1.992,1.772l-0,94.7c-0,4.831 4.526,8.858 9.958,8.858l16.478,-0c5.432,-0 9.958,-4.027 9.958,-8.858l0,-94.861c0,-0.967 0.906,-1.772 1.992,-1.772c0,0 25.35,-0.161 25.712,-0.322c1.086,-0.644 1.81,-1.771 1.81,-3.06l0,-14.173c0,-1.932 -1.81,-3.543 -4.164,-3.543l-25.169,0l0,-0.161l-0.181,0l0,-5.315c0,-0.966 0.906,-1.771 1.992,-1.771l23.358,-0c2.173,-0 3.983,-1.611 3.983,-3.543l0,-14.334c0,-1.933 -1.81,-3.543 -3.983,-3.543l-23.358,-0c-1.086,-0 -1.992,-0.806 -1.992,-1.772l0,-9.18c0,-2.255 2.173,-4.349 5.07,-4.349l3.078,0c2.173,0 3.441,-2.093 3.984,-4.187l3.078,-9.502c0.362,-1.289 1.63,-2.416 3.078,-2.899c23.358,-5.154 32.955,-20.454 40.922,-44.451l-0,-0.161c0.422,-2.854 -0.258,-4.622 -1.252,-5.729l101.379,101.379Zm-375.729,-61.204c4.362,3.788 9.511,6.914 15.588,9.039c1.267,0.483 2.716,0.966 3.983,1.288c1.811,0.322 2.535,1.772 2.898,2.738l3.078,9.502c0.543,2.255 2.173,4.187 3.983,4.187l3.078,0c2.716,0 4.889,1.933 5.07,4.349l0,6.575l-37.678,-37.678Zm9.606,62.5c0.716,0.602 1.677,0.975 2.723,0.975l23.358,-0c1.086,-0 1.991,0.805 1.991,1.771l0,3.866c0,0.966 -0.905,1.771 -1.991,1.771l-17.698,0l-8.383,-8.383Zm0.033,28.751c0.543,0.537 1.236,0.891 1.965,0.891l24.264,0c1.086,0 1.991,0.806 1.991,1.772l0,25.557l-28.22,-28.22Zm170.721,-64.819l-0,14.012c-0,1.933 -1.268,3.382 -2.897,3.382l-32.593,0c-1.629,0 -2.897,-1.449 -2.897,-3.382l0,-14.012c0,-1.771 1.268,-3.382 2.897,-3.382l32.593,0c1.448,0.161 2.897,1.611 2.897,3.382Zm-67.176,0l-0,14.012c-0,1.772 -1.268,3.382 -2.897,3.382l-32.593,0c-1.629,0 -2.897,-1.449 -2.897,-3.382l0,-14.012c0,-1.771 1.268,-3.382 2.897,-3.382l32.593,0c1.448,0.161 2.897,1.611 2.897,3.382Z" style="fill:#630b28;"/>
<path id="Icon" d="M395.165,143.677l-1.087,0c-53.234,17.716 -122.945,17.716 -142.319,17.394l-17.926,-0.322c-52.872,-1.933 -79.851,-22.225 -127.109,-43.323c-3.26,-1.45 -7.062,0.966 -6.7,4.348c0.362,11.596 3.44,60.234 39.835,72.958c1.267,0.483 2.716,0.966 3.983,1.288c1.811,0.322 2.535,1.772 2.898,2.738l3.078,9.502c0.543,2.255 2.173,4.187 3.983,4.187l3.078,0c2.716,0 4.889,1.933 5.07,4.349l0,9.18c0,0.966 -0.905,1.772 -1.991,1.772l-23.358,-0c-2.173,-0 -3.984,1.61 -3.984,3.543l0,14.334c0,1.932 1.811,3.543 3.984,3.543l23.358,-0c1.086,-0 1.991,0.805 1.991,1.771l0,3.866c0,0.966 -0.905,1.771 -1.991,1.771l-23.358,0c-2.173,0.161 -3.803,1.611 -3.803,3.543l0,14.334c0,1.611 1.449,3.382 3.078,3.382l24.264,0c1.086,0 1.991,0.806 1.991,1.772l0,94.216c0,4.832 4.527,8.858 9.959,8.858l16.477,0c5.432,0 9.959,-4.026 9.959,-8.858l-0,-94.216c-0,-0.966 0.905,-1.772 1.992,-1.772l101.76,-0.161c1.086,0 1.992,0.806 1.992,1.772l-0,94.7c-0,4.831 4.526,8.858 9.958,8.858l16.478,-0c5.432,-0 9.958,-4.027 9.958,-8.858l0,-94.861c0,-0.967 0.906,-1.772 1.992,-1.772c0,0 25.35,-0.161 25.712,-0.322c1.086,-0.644 1.81,-1.771 1.81,-3.06l0,-14.173c0,-1.932 -1.81,-3.543 -4.164,-3.543l-25.169,0l0,-0.161l-0.181,0l0,-5.315c0,-0.966 0.906,-1.771 1.992,-1.771l23.358,-0c2.173,-0 3.983,-1.611 3.983,-3.543l0,-14.334c0,-1.933 -1.81,-3.543 -3.983,-3.543l-23.358,-0c-1.086,-0 -1.992,-0.806 -1.992,-1.772l0,-9.18c0,-2.255 2.173,-4.349 5.07,-4.349l3.078,0c2.173,0 3.441,-2.093 3.984,-4.187l3.078,-9.502c0.362,-1.289 1.63,-2.416 3.078,-2.899c23.358,-5.154 32.955,-20.454 40.922,-44.451l-0,-0.161c0.905,-6.12 -3.26,-7.247 -4.708,-7.57Zm-90.534,68.448l-0,14.012c-0,1.933 -1.268,3.382 -2.897,3.382l-32.593,0c-1.629,0 -2.897,-1.449 -2.897,-3.382l0,-14.012c0,-1.771 1.268,-3.382 2.897,-3.382l32.593,0c1.448,0.161 2.897,1.611 2.897,3.382Zm-67.176,0l-0,14.012c-0,1.772 -1.268,3.382 -2.897,3.382l-32.593,0c-1.629,0 -2.897,-1.449 -2.897,-3.382l0,-14.012c0,-1.771 1.268,-3.382 2.897,-3.382l32.593,0c1.448,0.161 2.897,1.611 2.897,3.382Z" style="fill:#fff;fill-rule:nonzero;"/>
<defs>
<linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(3.06162e-14,500,-500,3.06162e-14,267.59,0)"><stop offset="0" style="stop-color:#f6cadc;stop-opacity:1"/><stop offset="1" style="stop-color:#7f0d18;stop-opacity:1"/></linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

19
docs/_static/jinja-name.svg vendored Normal file
View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 664 300" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g>
<path id="Name" d="M416,89.625l0,68.7c0,14.3 -2.95,24.375 -8.85,30.225c-5.9,5.85 -14.45,8.775 -25.65,8.775c-7.2,-0 -13.225,-0.95 -18.075,-2.85c-4.85,-1.9 -9.325,-4.9 -13.425,-9l11.7,-12.75c1.7,1.7 4.275,3.125 7.725,4.275c3.45,1.15 7.4,1.725 11.85,1.725c4.45,-0 7.875,-1.075 10.275,-3.225c2.4,-2.15 3.6,-6.175 3.6,-12.075l0,-73.8l20.85,-0Z" style="fill-rule:nonzero;"/>
<path d="M446.45,78.075c4.7,-0 7.75,0.725 9.15,2.175c1.4,1.45 2.1,4.5 2.1,9.15c0,4.65 -0.725,7.7 -2.175,9.15c-1.45,1.45 -4.5,2.175 -9.15,2.175c-4.65,-0 -7.7,-0.75 -9.15,-2.25c-1.45,-1.5 -2.175,-4.55 -2.175,-9.15c0,-4.6 0.725,-7.625 2.175,-9.075c1.45,-1.45 4.525,-2.175 9.225,-2.175Zm9.6,118.35l-19.5,-0l0,-82.5l19.5,-0l0,82.5Z" style="fill-rule:nonzero;"/>
<path d="M544.25,196.425l-19.5,-0l0,-54.75c0,-4.9 -1,-8.25 -3,-10.05c-2,-1.8 -4.8,-2.7 -8.4,-2.7l-17.55,7.35l0,60.15l-19.5,-0l0,-85.65l14.55,-0l4.5,10.2l24,-11.1c6.7,-0 12.525,2.475 17.475,7.425c4.95,4.95 7.425,12.175 7.425,21.675l0,57.45Z" style="fill-rule:nonzero;"/>
<path d="M583.25,113.925l0,85.65c0,6.1 -1.925,11.35 -5.775,15.75c-3.85,4.4 -9.525,6.6 -17.025,6.6l-11.1,-0l0,-16.5l7.5,-0c4.6,-0 6.9,-2.35 6.9,-7.05l0,-84.45l19.5,-0Zm-9.6,-35.85c4.7,-0 7.75,0.725 9.15,2.175c1.4,1.45 2.1,4.5 2.1,9.15c0,4.65 -0.725,7.7 -2.175,9.15c-1.45,1.45 -4.5,2.175 -9.15,2.175c-4.65,-0 -7.7,-0.75 -9.15,-2.25c-1.45,-1.5 -2.175,-4.55 -2.175,-9.15c0,-4.6 0.725,-7.625 2.175,-9.075c1.45,-1.45 4.525,-2.175 9.225,-2.175Z" style="fill-rule:nonzero;"/>
<path d="M663.95,196.425l-13.05,-0l-6,-10.35l-20.85,11.25c-11.6,-0 -19.4,-4.2 -23.4,-12.6c-2,-4.1 -3.375,-8.525 -4.125,-13.275c-0.75,-4.75 -1.125,-9.7 -1.125,-14.85c0,-5.15 0.05,-8.95 0.15,-11.4c0.1,-2.45 0.35,-5.3 0.75,-8.55c0.4,-3.25 0.975,-5.975 1.725,-8.175c0.75,-2.2 1.825,-4.475 3.225,-6.825c1.4,-2.35 3.1,-4.225 5.1,-5.625c4.5,-3.1 10.35,-4.65 17.55,-4.65l20.55,-0l19.5,-1.2l0,86.25Zm-19.5,-27.3l0,-40.2l-14.85,-0c-5.5,-0 -9.325,2.1 -11.475,6.3c-2.15,4.2 -3.225,10.475 -3.225,18.825c0,8.35 1.025,14.225 3.075,17.625c2.05,3.4 5.925,5.1 11.625,5.1l14.85,-7.65Z" style="fill-rule:nonzero;"/>
<g id="Logo">
<path id="Box" d="M300,30l-0,240c-0,16.557 -13.443,30 -30,30l-240,-0c-16.557,-0 -30,-13.443 -30,-30l0,-240c0,-16.557 13.443,-30 30,-30l240,0c16.557,0 30,13.443 30,30Z" style="fill:url(#_Linear1);"/>
<path id="Shadow" d="M300,148.138l0,121.862c0,16.557 -13.443,30 -30,30l-98.988,-0l-71.911,-71.911c1.081,0.937 2.551,1.52 4.152,1.52l9.887,-0c3.259,-0 5.975,-2.416 5.975,-5.315l-0,-56.53c-0,-0.58 0.543,-1.063 1.195,-1.063l61.056,-0.096c0.652,-0 1.195,0.483 1.195,1.063l0,56.819c0,2.899 2.716,5.315 5.975,5.315l9.887,0c3.259,0 5.975,-2.416 5.975,-5.315l-0,-56.916c-0,-0.58 0.543,-1.063 1.195,-1.063c0,-0 15.21,-0.097 15.427,-0.193c0.652,-0.387 1.086,-1.063 1.086,-1.836l0,-8.504c0,-1.16 -1.086,-2.126 -2.498,-2.126l-15.101,0l-0,-0.097l-0.109,0l-0,-3.188c-0,-0.58 0.543,-1.063 1.195,-1.063l14.015,-0c1.303,-0 2.39,-0.967 2.39,-2.126l-0,-8.601c-0,-1.159 -1.087,-2.125 -2.39,-2.125l-14.015,-0c-0.652,-0 -1.195,-0.484 -1.195,-1.063l-0,-5.508c-0,-1.353 1.304,-2.61 3.042,-2.61l1.847,0c1.304,0 2.064,-1.256 2.39,-2.512l1.847,-5.701c0.217,-0.773 0.978,-1.45 1.847,-1.74c14.014,-3.092 19.772,-12.272 24.553,-26.67l-0,-0.097c0.253,-1.712 -0.155,-2.773 -0.751,-3.437l60.827,60.827Zm-225.437,-36.722c2.617,2.273 5.706,4.148 9.352,5.423c0.761,0.29 1.63,0.58 2.39,0.773c1.087,0.193 1.521,1.063 1.739,1.643l1.847,5.701c0.326,1.353 1.303,2.512 2.39,2.512l1.847,0c1.629,0 2.933,1.16 3.042,2.61l-0,3.945l-22.607,-22.607Zm5.763,37.5c0.43,0.361 1.007,0.585 1.634,0.585l14.015,-0c0.651,-0 1.195,0.483 1.195,1.063l-0,2.319c-0,0.58 -0.544,1.063 -1.195,1.063l-10.619,-0l-5.03,-5.03Zm0.02,17.251c0.326,0.321 0.742,0.534 1.179,0.534l14.558,0c0.652,0 1.195,0.483 1.195,1.063l0,15.335l-16.932,-16.932Zm102.432,-38.892l0,8.407c0,1.16 -0.76,2.029 -1.738,2.029l-19.555,0c-0.978,0 -1.738,-0.869 -1.738,-2.029l-0,-8.407c-0,-1.063 0.76,-2.029 1.738,-2.029l19.555,-0c0.869,0.097 1.738,0.966 1.738,2.029Zm-40.305,0l-0,8.407c-0,1.063 -0.761,2.029 -1.738,2.029l-19.556,0c-0.978,0 -1.738,-0.869 -1.738,-2.029l-0,-8.407c-0,-1.063 0.76,-2.029 1.738,-2.029l19.556,-0c0.869,0.097 1.738,0.966 1.738,2.029Z" style="fill:#630b28;"/>
<path id="Icon" d="M237.099,86.206l-0.652,0c-31.94,10.63 -73.767,10.63 -85.392,10.437l-10.755,-0.194c-31.723,-1.159 -47.911,-13.335 -76.266,-25.994c-1.955,-0.869 -4.237,0.58 -4.02,2.609c0.218,6.958 2.065,36.141 23.901,43.775c0.761,0.29 1.63,0.58 2.39,0.773c1.087,0.193 1.521,1.063 1.739,1.643l1.847,5.701c0.326,1.353 1.303,2.512 2.39,2.512l1.847,0c1.629,0 2.933,1.16 3.042,2.61l-0,5.508c-0,0.579 -0.544,1.063 -1.195,1.063l-14.015,-0c-1.304,-0 -2.39,0.966 -2.39,2.125l-0,8.601c-0,1.159 1.086,2.126 2.39,2.126l14.015,-0c0.651,-0 1.195,0.483 1.195,1.063l-0,2.319c-0,0.58 -0.544,1.063 -1.195,1.063l-14.015,-0c-1.304,0.096 -2.282,0.966 -2.282,2.126l0,8.6c0,0.966 0.87,2.029 1.847,2.029l14.558,0c0.652,0 1.195,0.483 1.195,1.063l0,56.53c0,2.899 2.716,5.315 5.975,5.315l9.887,-0c3.259,-0 5.975,-2.416 5.975,-5.315l-0,-56.53c-0,-0.58 0.543,-1.063 1.195,-1.063l61.056,-0.096c0.652,-0 1.195,0.483 1.195,1.063l0,56.819c0,2.899 2.716,5.315 5.975,5.315l9.887,0c3.259,0 5.975,-2.416 5.975,-5.315l-0,-56.916c-0,-0.58 0.543,-1.063 1.195,-1.063c0,-0 15.21,-0.097 15.427,-0.193c0.652,-0.387 1.086,-1.063 1.086,-1.836l0,-8.504c0,-1.16 -1.086,-2.126 -2.498,-2.126l-15.101,0l-0,-0.097l-0.109,0l-0,-3.188c-0,-0.58 0.543,-1.063 1.195,-1.063l14.015,-0c1.303,-0 2.39,-0.967 2.39,-2.126l-0,-8.601c-0,-1.159 -1.087,-2.125 -2.39,-2.125l-14.015,-0c-0.652,-0 -1.195,-0.484 -1.195,-1.063l-0,-5.508c-0,-1.353 1.304,-2.61 3.042,-2.61l1.847,0c1.304,0 2.064,-1.256 2.39,-2.512l1.847,-5.701c0.217,-0.773 0.978,-1.45 1.847,-1.74c14.014,-3.092 19.772,-12.272 24.553,-26.67l-0,-0.097c0.543,-3.672 -1.956,-4.348 -2.825,-4.542Zm-54.321,41.069l0,8.407c0,1.16 -0.76,2.029 -1.738,2.029l-19.555,0c-0.978,0 -1.738,-0.869 -1.738,-2.029l-0,-8.407c-0,-1.063 0.76,-2.029 1.738,-2.029l19.555,-0c0.869,0.097 1.738,0.966 1.738,2.029Zm-40.305,0l-0,8.407c-0,1.063 -0.761,2.029 -1.738,2.029l-19.556,0c-0.978,0 -1.738,-0.869 -1.738,-2.029l-0,-8.407c-0,-1.063 0.76,-2.029 1.738,-2.029l19.556,-0c0.869,0.097 1.738,0.966 1.738,2.029Z" style="fill:#fff;fill-rule:nonzero;"/>
</g>
</g>
<defs>
<linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.83697e-14,300,-300,1.83697e-14,160.554,0)"><stop offset="0" style="stop-color:#f6cadc;stop-opacity:1"/><stop offset="1" style="stop-color:#7f0d18;stop-opacity:1"/></linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 6.9 KiB

26
docs/_static/jinja.js vendored
View File

@ -1,26 +0,0 @@
$(function() {
var
toc = $('#toc').show(),
items = $('#toc > ul').hide();
$('#toc h3')
.click(function() {
if (items.is(':visible')) {
items.animate({
height: 'hide',
opacity: 'hide'
}, 300, function() {
toc.removeClass('expandedtoc');
});
}
else {
items.animate({
height: 'show',
opacity: 'show'
}, 400);
toc.addClass('expandedtoc');
}
});
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

BIN
docs/_static/metal.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 B

BIN
docs/_static/note.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -1,5 +0,0 @@
div.header, div.relnav, #toc { display: none; }
#contentwrapper { padding: 0; margin: 0; border: none; }
body { color: black; background-color: white; }
div.footer { border-top: 1px solid #888; color: #888; margin-top: 1cm; }
div.footer a { text-decoration: none; }

390
docs/_static/style.css vendored
View File

@ -1,390 +0,0 @@
body {
background-color: #222;
margin: 0;
padding: 0;
font-family: 'Georgia', serif;
font-size: 15px;
color: #eee;
}
div.footer {
border-top: 1px solid #111;
padding: 8px;
font-size: 11px;
text-align: center;
letter-spacing: 0.5px;
}
div.footer a {
color: #eee;
}
div.header {
margin: 0 -15px 0 -15px;
background: url(headerbg.png) repeat-x;
border-top: 6px solid #D20000;
}
div.relnav {
border-bottom: 1px solid #111;
background: url(navigation.png);
margin: 0 -15px 0 -15px;
padding: 2px 20px 0 28px;
line-height: 25px;
color: #aaa;
font-size: 12px;
text-align: center;
}
div.relnav a {
color: #eee;
font-weight: bold;
text-decoration: none;
}
div.relnav a:hover {
text-decoration: underline;
}
#content {
background-color: white;
color: #111;
border-bottom: 1px solid black;
background: url(watermark.png) center 0;
padding: 0 15px 0 15px;
margin: 0;
}
h1 {
margin: 0;
padding: 15px 0 0 0;
}
h1.heading {
margin: 0;
padding: 0;
height: 80px;
}
h1.heading:hover {
background: #222;
}
h1.heading a {
background: url(jinjabanner.png) no-repeat center 0;
display: block;
width: 100%;
height: 80px;
}
h1.heading a:focus {
-moz-outline: none;
outline: none;
}
h1.heading span {
display: none;
}
#jinjalogo {
background-image: url(jinjalogo.png);
background-repeat: no-repeat;
width: 400px;
height: 160px;
}
#contentwrapper {
max-width: 680px;
padding: 0 18px 20px 18px;
margin: 0 auto 0 auto;
border-right: 1px solid #eee;
border-left: 1px solid #eee;
background: url(watermark_blur.png) center -114px;
}
#contentwrapper h2,
#contentwrapper h2 a {
color: #222;
font-size: 24px;
margin: 20px 0 0 0;
}
#contentwrapper h3,
#contentwrapper h3 a {
color: #b41717;
font-size: 20px;
margin: 20px 0 0 0;
}
table.docutils {
border-collapse: collapse;
border: 2px solid #aaa;
margin: 0.5em 1.5em 0.5em 1.5em;
}
table.docutils td {
padding: 2px;
border: 1px solid #ddd;
}
p, li, dd, dt, blockquote {
color: #333;
}
blockquote {
margin: 10px 0 10px 20px;
}
p {
line-height: 20px;
margin-bottom: 0;
margin-top: 10px;
}
hr {
border-top: 1px solid #ccc;
border-bottom: 0;
border-right: 0;
border-left: 0;
margin-bottom: 10px;
margin-top: 20px;
}
dl {
margin-left: 10px;
}
li, dt {
margin-top: 5px;
}
dt {
font-weight: bold;
color: #000;
}
dd {
margin-top: 10px;
line-height: 20px;
}
th {
text-align: left;
padding: 3px;
background-color: #f2f2f2;
}
a {
color: #b41717;
}
a:hover {
color: #444;
}
pre {
background: #ededed url(metal.png);
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
padding: 5px;
font-size: 13px;
font-family: 'Bitstream Vera Sans Mono', 'Monaco', monospace;
}
tt {
font-size: 13px;
font-family: 'Bitstream Vera Sans Mono', 'Monaco', monospace;
color: black;
padding: 1px 2px 1px 2px;
background-color: #fafafa;
border-bottom: 1px solid #eee;
}
a.reference:hover tt {
border-bottom-color: #aaa;
}
cite {
/* abusing <cite>, it's generated by ReST for `x` */
font-size: 13px;
font-family: 'Bitstream Vera Sans Mono', 'Monaco', monospace;
font-weight: bold;
font-style: normal;
}
div.admonition {
margin: 10px 0 10px 0;
padding: 10px 10px 10px 60px;
border: 1px solid #ccc;
}
div.admonition p.admonition-title {
background-color: #b41717;
color: white;
margin: -10px -10px 10px -60px;
padding: 4px 10px 4px 10px;
font-weight: bold;
font-size: 15px;
}
div.admonition p.admonition-title a {
color: white!important;
}
div.admonition-note {
background: url(note.png) no-repeat 10px 40px;
}
div.admonition-implementation {
background: url(implementation.png) no-repeat 10px 40px;
}
a.headerlink {
color: #B4B4B4!important;
font-size: 0.8em;
padding: 0 4px 0 4px;
text-decoration: none!important;
visibility: hidden;
}
h1:hover > a.headerlink,
h2:hover > a.headerlink,
h3:hover > a.headerlink,
h4:hover > a.headerlink,
h5:hover > a.headerlink,
h6:hover > a.headerlink,
dt:hover > a.headerlink,
dt:hover > a.headerlink {
visibility: visible;
}
a.headerlink:hover {
background-color: #B4B4B4;
color: #F0F0F0!important;
}
table.indextable {
width: 100%;
}
table.indextable td {
vertical-align: top;
width: 50%;
}
table.indextable dl dd {
font-size: 11px;
}
table.indextable dl dd a {
color: #000;
}
dl.function dt,
dl.class dt,
dl.exception dt,
dl.method dt,
dl.attribute dt {
font-weight: normal;
}
dt .descname {
font-weight: bold;
margin-right: 4px;
}
dt .descname, dt .descclassname {
padding: 0;
background: transparent;
border-bottom: 1px solid #111;
}
dt .descclassname {
margin-left: 2px;
}
dl dt big {
font-size: 100%;
}
ul.search {
margin: 10px 0 0 30px;
padding: 0;
}
ul.search li {
margin: 10px 0 0 0;
padding: 0;
}
ul.search div.context {
font-size: 12px;
padding: 4px 0 0 20px;
color: #888;
}
span.highlight {
background-color: #eee;
border: 1px solid #ccc;
}
#toc {
margin: 0 -17px 0 -17px;
display: none;
}
#toc h3 {
float: right;
margin: 5px 5px 0 0;
padding: 0;
font-size: 12px;
color: #777;
}
#toc h3:hover {
color: #333;
cursor: pointer;
}
.expandedtoc {
background: #222 url(darkmetal.png);
border-bottom: 1px solid #111;
outline-bottom: 1px solid #000;
padding: 5px;
}
.expandedtoc h3 {
color: #aaa;
margin: 0!important;
}
.expandedtoc h3:hover {
color: white!important;
}
#tod h3:hover {
color: white;
}
#toc a {
color: #ddd;
text-decoration: none;
}
#toc a:hover {
color: white;
text-decoration: underline;
}
#toc ul {
margin: 5px 0 12px 17px;
padding: 0 7px 0 7px;
}
#toc ul ul {
margin-bottom: 0;
}
#toc ul li {
margin: 2px 0 0 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

View File

View File

@ -1,36 +0,0 @@
{% extends "layout.html" %}
{% set title = 'Index' %}
{% block body %}
<h1 id="index">Index</h1>
{% for key, dummy in genindexentries -%}
<a href="#{{ key }}"><strong>{{ key }}</strong></a> {% if not loop.last %}| {% endif %}
{%- endfor %}
<hr>
{% for key, entries in genindexentries %}
<h2 id="{{ key }}">{{ key }}</h2>
<table class="indextable"><tr>
{%- for column in entries|slice(2) if column %}
<td><dl>
{%- for entryname, (links, subitems) in column %}
<dt>{% if links %}<a href="{{ links[0] }}">{{ entryname|e }}</a>
{% for link in links[1:] %}, <a href="{{ link }}">[Link]</a>{% endfor %}
{%- else %}{{ entryname|e }}{% endif %}</dt>
{%- if subitems %}
<dd><dl>
{%- for subentryname, subentrylinks in subitems %}
<dt><a href="{{ subentrylinks[0] }}">{{ subentryname|e }}</a>
{%- for link in subentrylinks[1:] %}, <a href="{{ link }}">[Link]</a>{% endfor -%}
</dt>
{%- endfor %}
</dl></dd>
{%- endif -%}
{%- endfor %}
</dl></td>
{%- endfor %}
</tr></table>
{% endfor %}
{% endblock %}

View File

@ -1,77 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Jinja2 Documentation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="{{ pathto('_static/style.css', 1) }}" type="text/css">
<link rel="stylesheet" href="{{ pathto('_static/print.css', 1) }}" type="text/css" media="print">
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css">
{%- if builder != 'htmlhelp' %}
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '{{ pathto("", 1) }}',
VERSION: '{{ release }}'
};
</script>
<script type="text/javascript" src="{{ pathto('_static/jquery.js', 1) }}"></script>
<script type="text/javascript" src="{{ pathto('_static/interface.js', 1) }}"></script>
<script type="text/javascript" src="{{ pathto('_static/doctools.js', 1) }}"></script>
<script type="text/javascript" src="{{ pathto('_static/jinja.js', 1) }}"></script>
{%- endif %}
{%- if use_opensearch and builder != 'htmlhelp' %}
<link rel="search" type="application/opensearchdescription+xml"
title="Search within {{ docstitle }}"
href="{{ pathto('_static/opensearch.xml', 1) }}">
{%- endif %}
{%- if hasdoc('about') %}
<link rel="author" title="About these documents" href="{{ pathto('about') }}">
{%- endif %}
<link rel="contents" title="Global table of contents" href="{{ pathto('contents') }}">
<link rel="index" title="Global index" href="{{ pathto('genindex') }}">
<link rel="search" title="Search" href="{{ pathto('search') }}">
{%- if hasdoc('copyright') %}
<link rel="copyright" title="Copyright" href="{{ pathto('copyright') }}">
{%- endif %}
<link rel="top" title="{{ docstitle }}" href="{{ pathto('index') }}">
{%- if parents %}
<link rel="up" title="{{ parents[-1].title|striptags }}" href="{{ parents[-1].link|e }}">
{%- endif %}
{%- if next %}
<link rel="next" title="{{ next.title|striptags }}" href="{{ next.link|e }}">
{%- endif %}
{%- if prev %}
<link rel="prev" title="{{ prev.title|striptags }}" href="{{ prev.link|e }}">
{%- endif %}
{% block extrahead %}{% endblock %}
</head>
<body>
<div id="content">
<div class="header">
<h1 class="heading"><a href="{{ pathto('index') }}"
title="back to the documentation overview"><span>Jinja</span></a></h1>
</div>
<div class="relnav">
{%- if prev %}
<a href="{{ prev.link|e }}">&laquo; {{ prev.title }}</a> |
{%- endif %}
<a href="{{ pathto(current_page_name) if current_page_name else '#' }}">{{ title }}</a>
{%- if next %}
| <a href="{{ next.link|e }}">{{ next.title }} &raquo;</a>
{%- endif %}
</div>
<div id="contentwrapper">
{%- if display_toc %}
<div id="toc">
<h3>Table Of Contents</h3>
{{ toc }}
</div>
{%- endif %}
{% block body %}{% endblock %}
</div>
</div>
<div class="footer">
© Copyright 2008 by the <a href="http://pocoo.org/">Pocoo Team</a>,
documentation generated by <a href="http://sphinx.pocoo.org/">Sphinx</a>
</div>
</body>
</html>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>{{ project }}</ShortName>
<Description>Search {{ docstitle }}</Description>
<InputEncoding>utf-8</InputEncoding>
<Url type="text/html" method="get"
template="{{ use_opensearch }}/{{ pathto('search') }}?q={searchTerms}&amp;check_keywords=yes&amp;area=default"/>
<LongName>{{ docstitle }}</LongName>
</OpenSearchDescription>

View File

@ -1,4 +0,0 @@
{% extends 'layout.html' %}
{% block body %}
{{ body }}
{% endblock %}

View File

@ -1,35 +0,0 @@
{% extends "layout.html" %}
{% set title = 'Search' %}
{% block extrahead %}
<script type="text/javascript" src="{{ pathto('_static/searchtools.js', 1) }}"></script>
{% endblock %}
{% block body %}
<h1 id="search-documentation">Search</h1>
<p>
From here you can search these documents. Enter your search
words into the box below and click "search". Note that the search
function will automatically search for all of the words. Pages
containing less words won't appear in the result list.
</p>
<form action="" method="get"><p>
<input type="text" name="q" value="">
<input type="submit" value="search">
</p></form>
{% if search_performed %}
<h2>Search Results</h2>
{% if not search_results %}
<p>Your search did not match any results.</p>
{% endif %}
{% endif %}
<div id="search-results">
{% if search_results %}
<ul>
{% for href, caption, context in search_results %}
<li><a href="{{ pathto(item.href) }}">{{ caption }}</a>
<div class="context">{{ context|e }}</div>
</li>
{% endfor %}
</ul>
{% endif %}
</div>
{% endblock %}

View File

@ -2,120 +2,87 @@ API
===
.. module:: jinja2
:synopsis: public Jinja2 API
:noindex:
:synopsis: public Jinja API
This document describes the API to Jinja2 and not the template language. It
will be most useful as reference to those implementing the template interface
to the application and not those who are creating Jinja2 templates.
This document describes the API to Jinja and not the template language
(for that, see :doc:`/templates`). It will be most useful as reference
to those implementing the template interface to the application and not
those who are creating Jinja templates.
Basics
------
Jinja2 uses a central object called the template :class:`Environment`.
Instances of this class are used to store the configuration, global objects
Jinja uses a central object called the template :class:`Environment`.
Instances of this class are used to store the configuration and global objects,
and are used to load templates from the file system or other locations.
Even if you are creating templates from strings by using the constructor of
:class:`Template` class, an environment is created automatically for you,
albeit a shared one.
Most applications will create one :class:`Environment` object on application
initialization and use that to load templates. In some cases it's however
initialization and use that to load templates. In some cases however, it's
useful to have multiple environments side by side, if different configurations
are in use.
The simplest way to configure Jinja2 to load templates for your application
looks roughly like this::
The simplest way to configure Jinja to load templates for your
application is to use :class:`~loaders.PackageLoader`.
from jinja2 import Environment, PackageLoader
env = Environment(loader=PackageLoader('yourapplication', 'templates'))
.. code-block:: python
This will create a template environment with the default settings and a
loader that looks up the templates in the `templates` folder inside the
`yourapplication` python package. Different loaders are available
and you can also write your own if you want to load templates from a
database or other resources.
from jinja2 import Environment, PackageLoader, select_autoescape
env = Environment(
loader=PackageLoader("yourapp"),
autoescape=select_autoescape()
)
To load a template from this environment you just have to call the
:meth:`get_template` method which then returns the loaded :class:`Template`::
This will create a template environment with a loader that looks up
templates in the ``templates`` folder inside the ``yourapp`` Python
package (or next to the ``yourapp.py`` Python module). It also enables
autoescaping for HTML files. This loader only requires that ``yourapp``
is importable, it figures out the absolute path to the folder for you.
template = env.get_template('mytemplate.html')
Different loaders are available to load templates in other ways or from
other locations. They're listed in the `Loaders`_ section below. You can
also write your own if you want to load templates from a source that's
more specialized to your project.
To render it with some variables, just call the :meth:`render` method::
To load a template from this environment, call the :meth:`get_template`
method, which returns the loaded :class:`Template`.
print template.render(the='variables', go='here')
.. code-block:: python
Using a template loader rather then passing strings to :class:`Template`
template = env.get_template("mytemplate.html")
To render it with some variables, call the :meth:`render` method.
.. code-block:: python
print(template.render(the="variables", go="here"))
Using a template loader rather than passing strings to :class:`Template`
or :meth:`Environment.from_string` has multiple advantages. Besides being
a lot easier to use it also enables template inheritance.
.. admonition:: Notes on Autoescaping
Unicode
-------
In future versions of Jinja we might enable autoescaping by default
for security reasons. As such you are encouraged to explicitly
configure autoescaping now instead of relying on the default.
Jinja2 is using unicode internally which means that you have to pass unicode
objects to the render function or bytestrings that only consist of ASCII
characters. Additionally newlines are normalized to one end of line
sequence which is per default UNIX style (``\n``).
Python 2.x supports two ways of representing string objects. One is the
`str` type and the other is the `unicode` type, both of which extend a type
called `basestring`. Unfortunately the default is `str` which should not
be used to store text based information unless only ASCII characters are
used. With Python 2.6 it is possible to make `unicode` the default on a per
module level and with Python 3 it will be the default.
To explicitly use a unicode string you have to prefix the string literal
with a `u`: ``u'Hänsel und Gretel sagen Hallo'``. That way Python will
store the string as unicode by decoding the string with the character
encoding from the current Python module. If no encoding is specified this
defaults to 'ASCII' which means that you can't use any non ASCII identifier.
To set a better module encoding add the following comment to the first or
second line of the Python module using the unicode literal::
# -*- coding: utf-8 -*-
We recommend utf-8 as Encoding for Python modules and templates as it's
possible to represent every Unicode character in utf-8 and because it's
backwards compatible to ASCII. For Jinja2 the default encoding of templates
is assumed to be utf-8.
It is not possible to use Jinja2 to process non unicode data. The reason
for this is that Jinja2 uses Unicode already on the language level. For
example Jinja2 treats the non-breaking space as valid whitespace inside
expressions which requires knowledge of the encoding or operating on an
unicode string.
For more details about unicode in Python have a look at the excellent
`Unicode documentation`_.
Another important thing is how Jinja2 is handling string literals in
templates. A naive implementation would be using unicode strings for
all string literals but it turned out in the past that this is problematic
as some libraries are typechecking against `str` explicitly. For example
`datetime.strftime` does not accept unicode arguments. To not break it
completely Jinja2 is returning `str` for strings that fit into ASCII and
for everything else `unicode`:
>>> m = Template(u"{% set a, b = 'foo', 'föö' %}").module
>>> m.a
'foo'
>>> m.b
u'f\xf6\xf6'
.. _Unicode documentation: http://docs.python.org/dev/howto/unicode.html
High Level API
--------------
The high-level API is the API you will use in the application to load and
render Jinja2 templates. The :ref:`low-level-api` on the other side is only
useful if you want to dig deeper into Jinja2 or :ref:`develop extensions
render Jinja templates. The :ref:`low-level-api` on the other side is only
useful if you want to dig deeper into Jinja or :ref:`develop extensions
<jinja-extensions>`.
.. autoclass:: Environment([options])
:members: from_string, get_template, join_path, extend, compile_expression
:members: from_string, get_template, select_template,
get_or_select_template, join_path, extend, compile_expression,
compile_templates, list_templates, add_extension
.. attribute:: shared
@ -147,10 +114,29 @@ useful if you want to dig deeper into Jinja2 or :ref:`develop extensions
.. attribute:: globals
A dict of global variables. These variables are always available
in a template. As long as no template was loaded it's safe
to modify this dict. For more details see :ref:`global-namespace`.
For valid object names have a look at :ref:`identifier-naming`.
A dict of variables that are available in every template loaded
by the environment. As long as no template was loaded it's safe
to modify this. For more details see :ref:`global-namespace`.
For valid object names see :ref:`identifier-naming`.
.. attribute:: policies
A dictionary with :ref:`policies`. These can be reconfigured to
change the runtime behavior or certain template features. Usually
these are security related.
.. attribute:: code_generator_class
The class used for code generation. This should not be changed
in most cases, unless you need to modify the Python code a
template compiles to.
.. attribute:: context_class
The context used for templates. This should not be changed
in most cases, unless you need to modify internals of how
template variables are handled. For details, see
:class:`~jinja2.runtime.Context`.
.. automethod:: overlay([options])
@ -165,7 +151,7 @@ useful if you want to dig deeper into Jinja2 or :ref:`develop extensions
provided as `exc` is raised if something with the generated undefined
object is done that the undefined object does not allow. The default
exception is :exc:`UndefinedError`. If a `hint` is provided the
`name` may be ommited.
`name` may be omitted.
The most common way to create an undefined object is by providing
a name only::
@ -182,10 +168,10 @@ useful if you want to dig deeper into Jinja2 or :ref:`develop extensions
For a more complex example you can provide a hint. For example
the :func:`first` filter creates an undefined object that way::
return environment.undefined('no first item, sequence was empty')
return environment.undefined('no first item, sequence was empty')
If it the `name` or `obj` is known (for example because an attribute
was accessed) it shold be passed to the undefined object, even if
was accessed) it should be passed to the undefined object, even if
a custom `hint` is provided. This gives undefined objects the
possibility to enhance the error message.
@ -194,9 +180,20 @@ useful if you want to dig deeper into Jinja2 or :ref:`develop extensions
.. attribute:: globals
The dict with the globals of that template. It's unsafe to modify
this dict as it may be shared with other templates or the environment
that loaded the template.
A dict of variables that are available every time the template
is rendered, without needing to pass them during render. This
should not be modified, as depending on how the template was
loaded it may be shared with the environment and other
templates.
Defaults to :attr:`Environment.globals` unless extra values are
passed to :meth:`Environment.get_template`.
Globals are only intended for data that is common to every
render of the template. Specific data should be passed to
:meth:`render`.
See :ref:`global-namespace`.
.. attribute:: name
@ -214,27 +211,69 @@ useful if you want to dig deeper into Jinja2 or :ref:`develop extensions
.. automethod:: stream([context])
.. automethod:: render_async([context])
.. automethod:: generate_async([context])
.. autoclass:: jinja2.environment.TemplateStream()
:members: disable_buffering, enable_buffering, dump
Autoescaping
------------
.. versionchanged:: 2.4
Jinja now comes with autoescaping support. As of Jinja 2.9 the
autoescape extension is removed and built-in. However autoescaping is
not yet enabled by default though this will most likely change in the
future. It's recommended to configure a sensible default for
autoescaping. This makes it possible to enable and disable autoescaping
on a per-template basis (HTML versus text for instance).
.. autofunction:: jinja2.select_autoescape
Here a recommended setup that enables autoescaping for templates ending
in ``'.html'``, ``'.htm'`` and ``'.xml'`` and disabling it by default
for all other extensions. You can use the :func:`~jinja2.select_autoescape`
function for this::
from jinja2 import Environment, PackageLoader, select_autoescape
env = Environment(autoescape=select_autoescape(['html', 'htm', 'xml']),
loader=PackageLoader('mypackage'))
The :func:`~jinja.select_autoescape` function returns a function that
works roughly like this::
def autoescape(template_name):
if template_name is None:
return False
if template_name.endswith(('.html', '.htm', '.xml'))
When implementing a guessing autoescape function, make sure you also
accept `None` as valid template name. This will be passed when generating
templates from strings. You should always configure autoescaping as
defaults in the future might change.
Inside the templates the behaviour can be temporarily changed by using
the `autoescape` block (see :ref:`autoescape-overrides`).
.. _identifier-naming:
Notes on Identifiers
--------------------
Jinja2 uses the regular Python 2.x naming rules. Valid identifiers have to
match ``[a-zA-Z_][a-zA-Z0-9_]*``. As a matter of fact non ASCII characters
are currently not allowed. This limitation will probably go away as soon as
unicode identifiers are fully specified for Python 3.
Jinja uses Python naming rules. Valid identifiers can be any combination
of characters accepted by Python.
Filters and tests are looked up in separate namespaces and have slightly
modified identifier syntax. Filters and tests may contain dots to group
filters and tests by topic. For example it's perfectly valid to add a
function into the filter dict and call it `to.unicode`. The regular
function into the filter dict and call it `to.str`. The regular
expression for filter and test identifiers is
``[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)*```.
``[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)*``.
Undefined Types
@ -247,15 +286,15 @@ unable to look up a name or access an attribute one of those objects is
created and returned. Some operations on undefined values are then allowed,
others fail.
The closest to regular Python behavior is the `StrictUndefined` which
The closest to regular Python behavior is the :class:`StrictUndefined` which
disallows all operations beside testing if it's an undefined object.
.. autoclass:: jinja2.Undefined()
.. attribute:: _undefined_hint
Either `None` or an unicode string with the error message for
the undefined object.
Either `None` or a string with the error message for the
undefined object.
.. attribute:: _undefined_obj
@ -278,42 +317,54 @@ disallows all operations beside testing if it's an undefined object.
:attr:`_undefined_exception` with an error message generated
from the undefined hints stored on the undefined object.
.. autoclass:: jinja2.ChainableUndefined()
.. autoclass:: jinja2.DebugUndefined()
.. autoclass:: jinja2.StrictUndefined()
There is also a factory function that can decorate undefined objects to
implement logging on failures:
.. autofunction:: jinja2.make_logging_undefined
Undefined objects are created by calling :attr:`undefined`.
.. admonition:: Implementation
:class:`Undefined` objects are implemented by overriding the special
`__underscore__` methods. For example the default :class:`Undefined`
class implements `__unicode__` in a way that it returns an empty
string, however `__int__` and others still fail with an exception. To
allow conversion to int by returning ``0`` you can implement your own::
:class:`Undefined` is implemented by overriding the special
``__underscore__`` methods. For example the default
:class:`Undefined` class implements ``__str__`` to returns an empty
string, while ``__int__`` and others fail with an exception. To
allow conversion to int by returning ``0`` you can implement your
own subclass.
.. code-block:: python
class NullUndefined(Undefined):
def __int__(self):
return 0
def __float__(self):
return 0.0
To disallow a method, just override it and raise
:attr:`~Undefined._undefined_exception`. Because this is a very common
idom in undefined objects there is the helper method
:meth:`~Undefined._fail_with_undefined_error` that does the error raising
automatically. Here a class that works like the regular :class:`Undefined`
but chokes on iteration::
To disallow a method, override it and raise
:attr:`~Undefined._undefined_exception`. Because this is very
common there is the helper method
:meth:`~Undefined._fail_with_undefined_error` that raises the error
with the correct information. Here's a class that works like the
regular :class:`Undefined` but fails on iteration::
class NonIterableUndefined(Undefined):
__iter__ = Undefined._fail_with_undefined_error
def __iter__(self):
self._fail_with_undefined_error()
The Context
-----------
.. autoclass:: jinja2.runtime.Context()
:members: resolve, get_exported, get_all
:members: get, resolve, resolve_or_missing, get_exported, get_all
.. attribute:: parent
@ -352,19 +403,26 @@ The Context
blocks registered. The last item in each list is the current active
block (latest in the inheritance chain).
.. attribute:: eval_ctx
The current :ref:`eval-context`.
.. automethod:: jinja2.runtime.Context.call(callable, \*args, \**kwargs)
.. admonition:: Implementation
The context is immutable, it prevents modifications, and if it is
modified somehow despite that those changes may not show up. For
performance, Jinja does not use the context as data storage for, only as
a primary data source. Variables that the template does not define are
looked up in the context, but variables the template does define are
stored locally.
Context is immutable for the same reason Python's frame locals are
immutable inside functions. Both Jinja2 and Python are not using the
context / frame locals as data storage for variables but only as primary
data source.
Instead of modifying the context directly, a function should return
a value that can be assigned to a variable within the template itself.
When a template accesses a variable the template does not define, Jinja2
looks up the variable in the context, after that the variable is treated
as if it was defined in the template.
.. code-block:: jinja
{% set comments = get_latest_comments() %}
.. _loaders:
@ -382,7 +440,7 @@ own loader, subclass :class:`BaseLoader` and override `get_source`.
.. autoclass:: jinja2.BaseLoader
:members: get_source, load
Here a list of the builtin loaders Jinja2 provides:
Here a list of the builtin loaders Jinja provides:
.. autoclass:: jinja2.FileSystemLoader
@ -396,6 +454,8 @@ Here a list of the builtin loaders Jinja2 provides:
.. autoclass:: jinja2.ChoiceLoader
.. autoclass:: jinja2.ModuleLoader
.. _bytecode-cache:
@ -410,7 +470,7 @@ This is especially useful if you have a web application that is initialized on
the first request and Jinja compiles many templates at once which slows down
the application.
To use a bytecode cache, instanciate it and pass it to the :class:`Environment`.
To use a bytecode cache, instantiate it and pass it to the :class:`Environment`.
.. autoclass:: jinja2.BytecodeCache
:members: load_bytecode, dump_bytecode, clear
@ -439,42 +499,108 @@ Builtin bytecode caches:
.. autoclass:: jinja2.MemcachedBytecodeCache
Async Support
-------------
.. versionadded:: 2.9
Jinja supports the Python ``async`` and ``await`` syntax. For the
template designer, this support (when enabled) is entirely transparent,
templates continue to look exactly the same. However, developers should
be aware of the implementation as it affects what types of APIs you can
use.
By default, async support is disabled. Enabling it will cause the
environment to compile different code behind the scenes in order to
handle async and sync code in an asyncio event loop. This has the
following implications:
- The compiled code uses ``await`` for functions and attributes, and
uses ``async for`` loops. In order to support using both async and
sync functions in this context, a small wrapper is placed around
all calls and access, which adds overhead compared to purely async
code.
- Sync methods and filters become wrappers around their corresponding
async implementations where needed. For example, ``render`` invokes
``async_render``, and ``|map`` supports async iterables.
Awaitable objects can be returned from functions in templates and any
function call in a template will automatically await the result. The
``await`` you would normally add in Python is implied. For example, you
can provide a method that asynchronously loads data from a database, and
from the template designer's point of view it can be called like any
other function.
.. _policies:
Policies
--------
Starting with Jinja 2.9 policies can be configured on the environment
which can slightly influence how filters and other template constructs
behave. They can be configured with the
:attr:`~jinja2.Environment.policies` attribute.
Example::
env.policies['urlize.rel'] = 'nofollow noopener'
``truncate.leeway``:
Configures the leeway default for the `truncate` filter. Leeway as
introduced in 2.9 but to restore compatibility with older templates
it can be configured to `0` to get the old behavior back. The default
is `5`.
``urlize.rel``:
A string that defines the items for the `rel` attribute of generated
links with the `urlize` filter. These items are always added. The
default is `noopener`.
``urlize.target``:
The default target that is issued for links from the `urlize` filter
if no other target is defined by the call explicitly.
``urlize.extra_schemes``:
Recognize URLs that start with these schemes in addition to the
default ``http://``, ``https://``, and ``mailto:``.
``json.dumps_function``:
If this is set to a value other than `None` then the `tojson` filter
will dump with this function instead of the default one. Note that
this function should accept arbitrary extra arguments which might be
passed in the future from the filter. Currently the only argument
that might be passed is `indent`. The default dump function is
``json.dumps``.
``json.dumps_kwargs``:
Keyword arguments to be passed to the dump function. The default is
``{'sort_keys': True}``.
.. _ext-i18n-trimmed:
``ext.i18n.trimmed``:
If this is set to `True`, ``{% trans %}`` blocks of the
:ref:`i18n-extension` will always unify linebreaks and surrounding
whitespace as if the `trimmed` modifier was used.
Utilities
---------
These helper functions and classes are useful if you add custom filters or
functions to a Jinja2 environment.
functions to a Jinja environment.
.. autofunction:: jinja2.environmentfilter
.. autofunction:: jinja2.pass_context
.. autofunction:: jinja2.contextfilter
.. autofunction:: jinja2.pass_eval_context
.. autofunction:: jinja2.environmentfunction
.. autofunction:: jinja2.contextfunction
.. function:: escape(s)
Convert the characters ``&``, ``<``, ``>``, ``'``, and ``"`` in string `s`
to HTML-safe sequences. Use this if you need to display text that might
contain such characters in HTML. This function will not escaped objects
that do have an HTML representation such as already escaped data.
The return value is a :class:`Markup` string.
.. autofunction:: jinja2.pass_environment
.. autofunction:: jinja2.clear_caches
.. autofunction:: jinja2.is_undefined
.. autoclass:: jinja2.Markup([string])
:members: escape, unescape, striptags
.. admonition:: Note
The Jinja2 :class:`Markup` class is compatible with at least Pylons and
Genshi. It's expected that more template engines and framework will pick
up the `__html__` concept soon.
Exceptions
----------
@ -485,28 +611,28 @@ Exceptions
.. autoexception:: jinja2.TemplateNotFound
.. autoexception:: jinja2.TemplatesNotFound
.. autoexception:: jinja2.TemplateSyntaxError
.. attribute:: message
The error message as utf-8 bytestring.
The error message.
.. attribute:: lineno
The line number where the error occurred
The line number where the error occurred.
.. attribute:: name
The load name for the template as unicode string.
The load name for the template.
.. attribute:: filename
The filename that loaded the template as bytestring in the encoding
of the file system (most likely utf-8 or mbcs on Windows systems).
The filename that loaded the template in the encoding of the
file system (most likely utf-8, or mbcs on Windows systems).
The reason why the filename and error message are bytestrings and not
unicode strings is that Python 2.x is not using unicode for exceptions
and tracebacks as well as the compiler. This will change with Python 3.
.. autoexception:: jinja2.TemplateRuntimeError
.. autoexception:: jinja2.TemplateAssertionError
@ -516,53 +642,65 @@ Exceptions
Custom Filters
--------------
Custom filters are just regular Python functions that take the left side of
the filter as first argument and the the arguments passed to the filter as
extra arguments or keyword arguments.
Filters are Python functions that take the value to the left of the
filter as the first argument and produce a new value. Arguments passed
to the filter are passed after the value.
For example in the filter ``{{ 42|myfilter(23) }}`` the function would be
called with ``myfilter(42, 23)``. Here for example a simple filter that can
be applied to datetime objects to format them::
For example, the filter ``{{ 42|myfilter(23) }}`` is called behind the
scenes as ``myfilter(42, 23)``.
def datetimeformat(value, format='%H:%M / %d-%m-%Y'):
Jinja comes with some :ref:`built-in filters <builtin-filters>`. To use
a custom filter, write a function that takes at least a ``value``
argument, then register it in :attr:`Environment.filters`.
Here's a filter that formats datetime objects:
.. code-block:: python
def datetime_format(value, format="%H:%M %d-%m-%y"):
return value.strftime(format)
You can register it on the template environment by updating the
:attr:`~Environment.filters` dict on the environment::
environment.filters["datetime_format"] = datetime_format
environment.filters['datetimeformat'] = datetimeformat
Inside the template it can then be used as follows:
Now it can be used in templates:
.. sourcecode:: jinja
written on: {{ article.pub_date|datetimeformat }}
publication date: {{ article.pub_date|datetimeformat('%d-%m-%Y') }}
{{ article.pub_date|datetime_format }}
{{ article.pub_date|datetime_format("%B %Y") }}
Filters can also be passed the current template context or environment. This
is useful if a filter wants to return an undefined value or check the current
:attr:`~Environment.autoescape` setting. For this purpose two decorators
exist: :func:`environmentfilter` and :func:`contextfilter`.
Some decorators are available to tell Jinja to pass extra information to
the filter. The object is passed as the first argument, making the value
being filtered the second argument.
Here a small example filter that breaks a text into HTML line breaks and
paragraphs and marks the return value as safe HTML string if autoescaping is
enabled::
- :func:`pass_environment` passes the :class:`Environment`.
- :func:`pass_eval_context` passes the :ref:`eval-context`.
- :func:`pass_context` passes the current
:class:`~jinja2.runtime.Context`.
Here's a filter that converts line breaks into HTML ``<br>`` and ``<p>``
tags. It uses the eval context to check if autoescape is currently
enabled before escaping the input and marking the output safe.
.. code-block:: python
import re
from jinja2 import environmentfilter, Markup, escape
from jinja2 import pass_eval_context
from markupsafe import Markup, escape
_paragraph_re = re.compile(r'(?:\r\n|\r|\n){2,}')
@pass_eval_context
def nl2br(eval_ctx, value):
br = "<br>\n"
@environmentfilter
def nl2br(environment, value):
result = u'\n\n'.join(u'<p>%s</p>' % p.replace('\n', '<br>\n')
for p in _paragraph_re.split(escape(value)))
if environment.autoescape:
result = Markup(result)
return result
if eval_ctx.autoescape:
value = escape(value)
br = Markup(br)
Context filters work the same just that the first argument is the current
active :class:`Context` rather then the environment.
result = "\n\n".join(
f"<p>{br.join(p.splitlines())}</p>"
for p in re.split(r"(?:\r\n|\r(?!\n)|\n){2,}", value)
)
return Markup(result) if eval_ctx.autoescape else result
.. _writing-tests:
@ -570,52 +708,152 @@ active :class:`Context` rather then the environment.
Custom Tests
------------
Tests work like filters just that there is no way for a test to get access
to the environment or context and that they can't be chained. The return
value of a test should be `True` or `False`. The purpose of a test is to
give the template designers the possibility to perform type and conformability
checks.
Test are Python functions that take the value to the left of the test as
the first argument, and return ``True`` or ``False``. Arguments passed
to the test are passed after the value.
Here a simple test that checks if a variable is a prime number::
For example, the test ``{{ 42 is even }}`` is called behind the scenes
as ``is_even(42)``.
Jinja comes with some :ref:`built-in tests <builtin-tests>`. To use a
custom tests, write a function that takes at least a ``value`` argument,
then register it in :attr:`Environment.tests`.
Here's a test that checks if a value is a prime number:
.. code-block:: python
import math
def is_prime(n):
if n == 2:
return True
for i in xrange(2, int(math.ceil(math.sqrt(n))) + 1):
for i in range(2, int(math.ceil(math.sqrt(n))) + 1):
if n % i == 0:
return False
return True
You can register it on the template environment by updating the
:attr:`~Environment.tests` dict on the environment::
environment.tests["prime"] = is_prime
environment.tests['prime'] = is_prime
A template designer can then use the test like this:
Now it can be used in templates:
.. sourcecode:: jinja
{% if 42 is prime %}
42 is a prime number
{% if value is prime %}
{{ value }} is a prime number
{% else %}
42 is not a prime number
{{ value }} is not a prime number
{% endif %}
Some decorators are available to tell Jinja to pass extra information to
the test. The object is passed as the first argument, making the value
being tested the second argument.
- :func:`pass_environment` passes the :class:`Environment`.
- :func:`pass_eval_context` passes the :ref:`eval-context`.
- :func:`pass_context` passes the current
:class:`~jinja2.runtime.Context`.
.. _eval-context:
Evaluation Context
------------------
The evaluation context (short eval context or eval ctx) makes it
possible to activate and deactivate compiled features at runtime.
Currently it is only used to enable and disable automatic escaping, but
it can be used by extensions as well.
The ``autoescape`` setting should be checked on the evaluation context,
not the environment. The evaluation context will have the computed value
for the current template.
Instead of ``pass_environment``:
.. code-block:: python
@pass_environment
def filter(env, value):
result = do_something(value)
if env.autoescape:
result = Markup(result)
return result
Use ``pass_eval_context`` if you only need the setting:
.. code-block:: python
@pass_eval_context
def filter(eval_ctx, value):
result = do_something(value)
if eval_ctx.autoescape:
result = Markup(result)
return result
Or use ``pass_context`` if you need other context behavior as well:
.. code-block:: python
@pass_context
def filter(context, value):
result = do_something(value)
if context.eval_ctx.autoescape:
result = Markup(result)
return result
The evaluation context must not be modified at runtime. Modifications
must only happen with a :class:`nodes.EvalContextModifier` and
:class:`nodes.ScopedEvalContextModifier` from an extension, not on the
eval context object itself.
.. autoclass:: jinja2.nodes.EvalContext
.. attribute:: autoescape
`True` or `False` depending on if autoescaping is active or not.
.. attribute:: volatile
`True` if the compiler cannot evaluate some expressions at compile
time. At runtime this should always be `False`.
.. _global-namespace:
The Global Namespace
--------------------
Variables stored in the :attr:`Environment.globals` dict are special as they
are available for imported templates too, even if they are imported without
context. This is the place where you can put variables and functions
that should be available all the time. Additionally :attr:`Template.globals`
exist that are variables available to a specific template that are available
to all :meth:`~Template.render` calls.
The global namespace stores variables and functions that should be
available without needing to pass them to :meth:`Template.render`. They
are also available to templates that are imported or included without
context. Most applications should only use :attr:`Environment.globals`.
:attr:`Environment.globals` are intended for data that is common to all
templates loaded by that environment. :attr:`Template.globals` are
intended for data that is common to all renders of that template, and
default to :attr:`Environment.globals` unless they're given in
:meth:`Environment.get_template`, etc. Data that is specific to a
render should be passed as context to :meth:`Template.render`.
Only one set of globals is used during any specific rendering. If
templates A and B both have template globals, and B extends A, then
only B's globals are used for both when using ``b.render()``.
Environment globals should not be changed after loading any templates,
and template globals should not be changed at any time after loading the
template. Changing globals after loading a template will result in
unexpected behavior as they may be shared between the environment and
other templates.
.. _low-level-api:
@ -642,7 +880,7 @@ don't recommend using any of those.
that has to be created by :meth:`new_context` of the same template or
a compatible template. This render function is generated by the
compiler from the template code and returns a generator that yields
unicode strings.
strings.
If an exception in the template code happens the template engine will
not rewrite the exception but pass through the original one. As a
@ -661,9 +899,9 @@ don't recommend using any of those.
.. admonition:: Note
The low-level API is fragile. Future Jinja2 versions will try not to
change it in a backwards incompatible way but modifications in the Jinja2
core may shine through. For example if Jinja2 introduces a new AST node
The low-level API is fragile. Future Jinja versions will try not to
change it in a backwards incompatible way but modifications in the Jinja
core may shine through. For example if Jinja introduces a new AST node
in later versions that may be returned by :meth:`~Environment.parse`.
The Meta API

View File

@ -1,3 +0,0 @@
.. module:: jinja2
.. include:: ../CHANGES

4
docs/changes.rst Normal file
View File

@ -0,0 +1,4 @@
Changes
=======
.. include:: ../CHANGES.rst

View File

@ -1,141 +1,55 @@
# -*- coding: utf-8 -*-
#
# Jinja2 documentation build configuration file, created by
# sphinx-quickstart on Sun Apr 27 21:42:41 2008.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# The contents of this file are pickled, so don't put values in the namespace
# that aren't pickleable (module imports are okay, they're removed automatically).
#
# All configuration values have a default value; values that are commented out
# serve to show the default value.
from pallets_sphinx_themes import get_version
from pallets_sphinx_themes import ProjectLink
import sys, os
# Project --------------------------------------------------------------
# If your extensions are in another directory, add it here. If the directory
# is relative to the documentation root, use os.path.abspath to make it
# absolute, like shown here.
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
project = "Jinja"
copyright = "2007 Pallets"
author = "Pallets"
release, version = get_version("Jinja2")
# General configuration
# ---------------------
# General --------------------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'jinjaext']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
# General substitutions.
project = 'Jinja2'
copyright = '2008, Armin Ronacher'
# The default replacements for |version| and |release|, also used in various
# other places throughout the built documents.
#
# The short X.Y version.
version = '2.0'
# The full version, including alpha/beta/rc tags.
release = '2.0'
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
#unused_docs = []
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'jinjaext.JinjaStyle'
# Options for HTML output
# -----------------------
# The style sheet to use for HTML and HTML Help pages. A file of that name
# must exist either in Sphinx' static/ path, or in one of the custom paths
# given in html_static_path.
html_style = 'style.css'
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# no modindex
html_use_modindex = False
# If true, the reST sources are included in the HTML build as _sources/<name>.
#html_copy_source = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it.
#html_use_opensearch = False
# Output file base name for HTML help builder.
htmlhelp_basename = 'Jinja2doc'
# Options for LaTeX output
# ------------------------
# The paper size ('letter' or 'a4').
latex_paper_size = 'a4'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, document class [howto/manual]).
latex_documents = [
('index', 'Jinja2.tex', 'Jinja2 Documentation', 'Armin Ronacher', 'manual', 'toctree_only'),
default_role = "code"
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"sphinxcontrib.log_cabinet",
"pallets_sphinx_themes",
]
autodoc_member_order = "bysource"
autodoc_typehints = "description"
autodoc_preserve_defaults = True
extlinks = {
"issue": ("https://github.com/pallets/jinja/issues/%s", "#%s"),
"pr": ("https://github.com/pallets/jinja/pull/%s", "#%s"),
"ghsa": ("https://github.com/pallets/jinja/security/advisories/GHSA-%s", "GHSA-%s"),
}
intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
}
# Additional stuff for the LaTeX preamble.
latex_preamble = '''
\usepackage{palatino}
\definecolor{TitleColor}{rgb}{0.7,0,0}
\definecolor{InnerLinkColor}{rgb}{0.7,0,0}
\definecolor{OuterLinkColor}{rgb}{0.8,0,0}
\definecolor{VerbatimColor}{rgb}{0.985,0.985,0.985}
\definecolor{VerbatimBorderColor}{rgb}{0.8,0.8,0.8}
'''
# HTML -----------------------------------------------------------------
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
latex_use_modindex = False
html_theme = "jinja"
html_theme_options = {"index_sidebar_logo": False}
html_context = {
"project_links": [
ProjectLink("Donate", "https://palletsprojects.com/donate"),
ProjectLink("PyPI Releases", "https://pypi.org/project/Jinja2/"),
ProjectLink("Source Code", "https://github.com/pallets/jinja/"),
ProjectLink("Issue Tracker", "https://github.com/pallets/jinja/issues/"),
ProjectLink("Chat", "https://discord.gg/pallets"),
]
}
html_sidebars = {
"index": ["project.html", "localtoc.html", "searchbox.html", "ethicalads.html"],
"**": ["localtoc.html", "relations.html", "searchbox.html", "ethicalads.html"],
}
singlehtml_sidebars = {"index": ["project.html", "localtoc.html", "ethicalads.html"]}
html_static_path = ["_static"]
html_favicon = "_static/jinja-icon.svg"
html_logo = "_static/jinja-logo.svg"
html_title = f"Jinja Documentation ({version})"
html_show_sourcelink = False

View File

@ -4,42 +4,40 @@ from jinja2.ext import Extension
class FragmentCacheExtension(Extension):
# a set of names that trigger the extension.
tags = set(['cache'])
tags = {"cache"}
def __init__(self, environment):
super(FragmentCacheExtension, self).__init__(environment)
super().__init__(environment)
# add the defaults to the environment
environment.extend(
fragment_cache_prefix='',
fragment_cache=None
)
environment.extend(fragment_cache_prefix="", fragment_cache=None)
def parse(self, parser):
# the first token is the token that started the tag. In our case
# we only listen to ``'cache'`` so this will be a name token with
# `cache` as value. We get the line number so that we can give
# that line number to the nodes we create by hand.
lineno = parser.stream.next().lineno
lineno = next(parser.stream).lineno
# now we parse a single expression that is used as cache key.
args = [parser.parse_expression()]
# if there is a comma, the user provided a timeout. If not use
# None as second parameter.
if parser.stream.skip_if('comma'):
if parser.stream.skip_if("comma"):
args.append(parser.parse_expression())
else:
args.append(nodes.Const(None))
# now we parse the body of the cache block up to `endcache` and
# drop the needle (which would always be `endcache` in that case)
body = parser.parse_statements(['name:endcache'], drop_needle=True)
body = parser.parse_statements(["name:endcache"], drop_needle=True)
# now return a `CallBlock` node that calls our _cache_support
# helper method on this extension.
return nodes.CallBlock(self.call_method('_cache_support', args),
[], [], body).set_lineno(lineno)
return nodes.CallBlock(
self.call_method("_cache_support", args), [], [], body
).set_lineno(lineno)
def _cache_support(self, name, timeout, caller):
"""Helper callback."""

View File

@ -0,0 +1,71 @@
import re
from jinja2.exceptions import TemplateSyntaxError
from jinja2.ext import Extension
from jinja2.lexer import count_newlines
from jinja2.lexer import Token
_outside_re = re.compile(r"\\?(gettext|_)\(")
_inside_re = re.compile(r"\\?[()]")
class InlineGettext(Extension):
"""This extension implements support for inline gettext blocks::
<h1>_(Welcome)</h1>
<p>_(This is a paragraph)</p>
Requires the i18n extension to be loaded and configured.
"""
def filter_stream(self, stream):
paren_stack = 0
for token in stream:
if token.type != "data":
yield token
continue
pos = 0
lineno = token.lineno
while True:
if not paren_stack:
match = _outside_re.search(token.value, pos)
else:
match = _inside_re.search(token.value, pos)
if match is None:
break
new_pos = match.start()
if new_pos > pos:
preval = token.value[pos:new_pos]
yield Token(lineno, "data", preval)
lineno += count_newlines(preval)
gtok = match.group()
if gtok[0] == "\\":
yield Token(lineno, "data", gtok[1:])
elif not paren_stack:
yield Token(lineno, "block_begin", None)
yield Token(lineno, "name", "trans")
yield Token(lineno, "block_end", None)
paren_stack = 1
else:
if gtok == "(" or paren_stack > 1:
yield Token(lineno, "data", gtok)
paren_stack += -1 if gtok == ")" else 1
if not paren_stack:
yield Token(lineno, "block_begin", None)
yield Token(lineno, "name", "endtrans")
yield Token(lineno, "block_end", None)
pos = match.end()
if pos < len(token.value):
yield Token(lineno, "data", token.value[pos:])
if paren_stack:
raise TemplateSyntaxError(
"unclosed gettext expression",
token.lineno,
stream.name,
stream.filename,
)

View File

@ -3,59 +3,94 @@
Extensions
==========
Jinja2 supports extensions that can add extra filters, tests, globals or even
extend the parser. The main motivation of extensions is it to move often used
Jinja supports extensions that can add extra filters, tests, globals or even
extend the parser. The main motivation of extensions is to move often used
code into a reusable class like adding support for internationalization.
Adding Extensions
-----------------
Extensions are added to the Jinja2 environment at creation time. Once the
environment is created additional extensions cannot be added. To add an
Extensions are added to the Jinja environment at creation time. To add an
extension pass a list of extension classes or import paths to the
`environment` parameter of the :class:`Environment` constructor. The following
example creates a Jinja2 environment with the i18n extension loaded::
``extensions`` parameter of the :class:`~jinja2.Environment` constructor. The following
example creates a Jinja environment with the i18n extension loaded::
jinja_env = Environment(extensions=['jinja2.ext.i18n'])
To add extensions after creation time, use the :meth:`~jinja2.Environment.add_extension` method::
jinja_env.add_extension('jinja2.ext.debug')
.. _i18n-extension:
i18n Extension
--------------
**Import name:** `jinja2.ext.i18n`
**Import name:** ``jinja2.ext.i18n``
Jinja2 currently comes with one extension, the i18n extension. It can be
used in combination with `gettext`_ or `babel`_. If the i18n extension is
enabled Jinja2 provides a `trans` statement that marks the wrapped string as
translatable and calls `gettext`.
The i18n extension can be used in combination with `gettext`_ or
`Babel`_. When it's enabled, Jinja provides a ``trans`` statement that
marks a block as translatable and calls ``gettext``.
After enabling dummy `_` function that forwards calls to `gettext` is added
to the environment globals. An internationalized application then has to
provide at least an `gettext` and optoinally a `ngettext` function into the
namespace. Either globally or for each rendering.
After enabling, an application has to provide functions for ``gettext``,
``ngettext``, and optionally ``pgettext`` and ``npgettext``, either
globally or when rendering. A ``_()`` function is added as an alias to
the ``gettext`` function.
After enabling of the extension the environment provides the following
A convenient way to provide these functions is to call one of the below
methods depending on the translation system in use. If you do not require
actual translation, use ``Environment.install_null_translations`` to
install no-op functions.
Environment Methods
~~~~~~~~~~~~~~~~~~~
After enabling the extension, the environment provides the following
additional methods:
.. method:: jinja2.Environment.install_gettext_translations(translations)
.. method:: jinja2.Environment.install_gettext_translations(translations, newstyle=False)
Installs a translation globally for that environment. The tranlations
object provided must implement at least `ugettext` and `ungettext`.
The `gettext.NullTranslations` and `gettext.GNUTranslations` classes
as well as `Babel`_\s `Translations` class are supported.
Installs a translation globally for the environment. The
``translations`` object must implement ``gettext``, ``ngettext``,
and optionally ``pgettext`` and ``npgettext``.
:class:`gettext.NullTranslations`, :class:`gettext.GNUTranslations`,
and `Babel`_\s ``Translations`` are supported.
.. method:: jinja2.Environment.install_null_translations()
.. versionchanged:: 3.0
Added ``pgettext`` and ``npgettext``.
Install dummy gettext functions. This is useful if you want to prepare
the application for internationalization but don't want to implement the
full internationalization system yet.
.. versionchanged:: 2.5
Added new-style gettext support.
.. method:: jinja2.Environment.install_null_translations(newstyle=False)
Install no-op gettext functions. This is useful if you want to
prepare the application for internationalization but don't want to
implement the full system yet.
.. versionchanged:: 2.5 Added new-style gettext support.
.. method:: jinja2.Environment.install_gettext_callables(gettext, ngettext, newstyle=False, pgettext=None, npgettext=None)
Install the given ``gettext``, ``ngettext``, ``pgettext``, and
``npgettext`` callables into the environment. They should behave
exactly like :func:`gettext.gettext`, :func:`gettext.ngettext`,
:func:`gettext.pgettext` and :func:`gettext.npgettext`.
If ``newstyle`` is activated, the callables are wrapped to work like
newstyle callables. See :ref:`newstyle-gettext` for more information.
.. versionchanged:: 3.0
Added ``pgettext`` and ``npgettext``.
.. versionadded:: 2.5
Added new-style gettext support.
.. method:: jinja2.Environment.uninstall_gettext_translations()
Uninstall the translations again.
Uninstall the environment's globally installed translation.
.. method:: jinja2.Environment.extract_translations(source)
@ -64,40 +99,115 @@ additional methods:
For every string found this function yields a ``(lineno, function,
message)`` tuple, where:
* `lineno` is the number of the line on which the string was found,
* `function` is the name of the `gettext` function used (if the
string was extracted from embedded Python code), and
* `message` is the string itself (a `unicode` object, or a tuple
of `unicode` objects for functions with multiple string arguments).
- ``lineno`` is the number of the line on which the string was
found.
- ``function`` is the name of the ``gettext`` function used (if
the string was extracted from embedded Python code).
- ``message`` is the string itself, or a tuple of strings for
functions with multiple arguments.
If `Babel`_ is installed :ref:`the babel integration <babel-integration>`
can be used to extract strings for babel.
If `Babel`_ is installed, see :ref:`babel-integration` to extract
the strings.
For a web application that is available in multiple languages but gives all
the users the same language (for example a multilingual forum software
installed for a French community) may load the translations once and add the
translation methods to the environment at environment generation time::
For a web application that is available in multiple languages but gives
all the users the same language (for example, multilingual forum
software installed for a French community), the translation may be
installed when the environment is created.
.. code-block:: python
translations = get_gettext_translations()
env = Environment(extensions=['jinja2.ext.i18n'])
env = Environment(extensions=["jinja2.ext.i18n"])
env.install_gettext_translations(translations)
The `get_gettext_translations` function would return the translator for the
current configuration. (For example by using `gettext.find`)
The ``get_gettext_translations`` function would return the translator
for the current configuration, for example by using ``gettext.find``.
The usage of the `i18n` extension for template designers is covered as part
:ref:`of the template documentation <i18n-in-templates>`.
The usage of the ``i18n`` extension for template designers is covered in
:ref:`the template documentation <i18n-in-templates>`.
.. _gettext: http://docs.python.org/dev/library/gettext
.. _Babel: http://babel.edgewall.org/
.. _gettext: https://docs.python.org/3/library/gettext.html
.. _Babel: https://babel.pocoo.org/
Whitespace Trimming
~~~~~~~~~~~~~~~~~~~
.. versionadded:: 2.10
Within ``{% trans %}`` blocks, it can be useful to trim line breaks and
whitespace so that the block of text looks like a simple string with
single spaces in the translation file.
Linebreaks and surrounding whitespace can be automatically trimmed by
enabling the ``ext.i18n.trimmed`` :ref:`policy <ext-i18n-trimmed>`.
.. _newstyle-gettext:
New Style Gettext
~~~~~~~~~~~~~~~~~
.. versionadded:: 2.5
New style gettext calls are less to type, less error prone, and support
autoescaping better.
You can use "new style" gettext calls by setting
``env.newstyle_gettext = True`` or passing ``newstyle=True`` to
``env.install_translations``. They are fully supported by the Babel
extraction tool, but might not work as expected with other extraction
tools.
With standard ``gettext`` calls, string formatting is a separate step
done with the ``|format`` filter. This requires duplicating work for
``ngettext`` calls.
.. sourcecode:: jinja
{{ gettext("Hello, World!") }}
{{ gettext("Hello, %(name)s!")|format(name=name) }}
{{ ngettext(
"%(num)d apple", "%(num)d apples", apples|count
)|format(num=apples|count) }}
{{ pgettext("greeting", "Hello, World!") }}
{{ npgettext(
"fruit", "%(num)d apple", "%(num)d apples", apples|count
)|format(num=apples|count) }}
New style ``gettext`` make formatting part of the call, and behind the
scenes enforce more consistency.
.. sourcecode:: jinja
{{ gettext("Hello, World!") }}
{{ gettext("Hello, %(name)s!", name=name) }}
{{ ngettext("%(num)d apple", "%(num)d apples", apples|count) }}
{{ pgettext("greeting", "Hello, World!") }}
{{ npgettext("fruit", "%(num)d apple", "%(num)d apples", apples|count) }}
The advantages of newstyle gettext are:
- There's no separate formatting step, you don't have to remember to
use the ``|format`` filter.
- Only named placeholders are allowed. This solves a common problem
translators face because positional placeholders can't switch
positions meaningfully. Named placeholders always carry semantic
information about what value goes where.
- String formatting is used even if no placeholders are used, which
makes all strings use a consistent format. Remember to escape any
raw percent signs as ``%%``, such as ``100%%``.
- The translated string is marked safe, formatting performs escaping
as needed. Mark a parameter as ``|safe`` if it has already been
escaped.
Expression Statement
--------------------
**Import name:** `jinja2.ext.do`
**Import name:** ``jinja2.ext.do``
The "do" aka expression-statement extension adds a simple `do` tag to the
The "do" aka expression-statement extension adds a simple ``do`` tag to the
template engine that works like a variable expression but ignores the
return value.
@ -106,12 +216,47 @@ return value.
Loop Controls
-------------
**Import name:** `jinja2.ext.loopcontrols`
**Import name:** ``jinja2.ext.loopcontrols``
This extension adds support for `break` and `continue` in loops. After
enabling Jinja2 provides those two keywords which work exactly like in
This extension adds support for ``break`` and ``continue`` in loops. After
enabling, Jinja provides those two keywords which work exactly like in
Python.
.. _with-extension:
With Statement
--------------
**Import name:** ``jinja2.ext.with_``
.. versionchanged:: 2.9
This extension is now built-in and no longer does anything.
.. _autoescape-extension:
Autoescape Extension
--------------------
**Import name:** ``jinja2.ext.autoescape``
.. versionchanged:: 2.9
This extension was removed and is now built-in. Enabling the
extension no longer does anything.
.. _debug-extension:
Debug Extension
---------------
**Import name:** ``jinja2.ext.debug``
Adds a ``{% debug %}`` tag to dump the current context as well as the
available filters and tests. This is useful to see what's available to
use in the template without setting up a debugger.
.. _writing-extensions:
@ -120,31 +265,35 @@ Writing Extensions
.. module:: jinja2.ext
By writing extensions you can add custom tags to Jinja2. This is a non trival
By writing extensions you can add custom tags to Jinja. This is a non-trivial
task and usually not needed as the default tags and expressions cover all
common use cases. The i18n extension is a good example of why extensions are
useful, another one would be fragment caching.
useful. Another one would be fragment caching.
When writing extensions you have to keep in mind that you are working with the
Jinja2 template compiler which does not validate the node tree you are possing
Jinja template compiler which does not validate the node tree you are passing
to it. If the AST is malformed you will get all kinds of compiler or runtime
errors that are horrible to debug. Always make sure you are using the nodes
you create correctly. The API documentation below shows which nodes exist and
how to use them.
Example Extension
~~~~~~~~~~~~~~~~~
The following example implements a `cache` tag for Jinja2 by using the
`Werkzeug`_ caching contrib module:
Example Extensions
------------------
.. literalinclude:: cache_extension.py
Cache
~~~~~
The following example implements a ``cache`` tag for Jinja by using the
`cachelib`_ library:
.. literalinclude:: examples/cache_extension.py
:language: python
And here is how you use it in an environment::
from jinja2 import Environment
from werkzeug.contrib.cache import SimpleCache
from cachelib import SimpleCache
env = Environment(extensions=[FragmentCacheExtension])
env.fragment_cache = SimpleCache()
@ -160,10 +309,32 @@ following example caches a sidebar for 300 seconds:
</div>
{% endcache %}
.. _Werkzeug: http://werkzeug.pocoo.org/
.. _cachelib: https://github.com/pallets/cachelib
Inline ``gettext``
~~~~~~~~~~~~~~~~~~
The following example demonstrates using :meth:`Extension.filter_stream`
to parse calls to the ``_()`` gettext function inline with static data
without needing Jinja blocks.
.. code-block:: html
<h1>_(Welcome)</h1>
<p>_(This is a paragraph)</p>
It requires the i18n extension to be loaded and configured.
.. literalinclude:: examples/inline_gettext_extension.py
:language: python
Extension API
~~~~~~~~~~~~~
-------------
Extension
~~~~~~~~~
Extensions always have to extend the :class:`jinja2.ext.Extension` class:
@ -180,8 +351,9 @@ Extensions always have to extend the :class:`jinja2.ext.Extension` class:
If the extension implements custom tags this is a set of tag names
the extension is listening for.
Parser API
~~~~~~~~~~
Parser
~~~~~~
The parser passed to :meth:`Extension.parse` provides ways to parse
expressions of different types. The following methods may be used by
@ -196,7 +368,7 @@ extensions:
The filename of the template the parser processes. This is **not**
the load name of the template. For the load name see :attr:`name`.
For templates that were not loaded form the file system this is
`None`.
``None``.
.. attribute:: name
@ -207,7 +379,7 @@ extensions:
The current :class:`~jinja2.lexer.TokenStream`
.. autoclass:: jinja2.lexer.TokenStream
:members: push, look, eos, skip, next, next_if, skip_if, expect
:members: push, look, eos, skip, __next__, next_if, skip_if, expect
.. attribute:: current
@ -223,7 +395,7 @@ extensions:
.. attribute:: type
The type of the token. This string is interned so you may compare
it with arbitrary strings using the `is` operator.
it with arbitrary strings using the ``is`` operator.
.. attribute:: value
@ -234,6 +406,7 @@ characters in strings:
.. autofunction:: jinja2.lexer.count_newlines
AST
~~~
@ -243,12 +416,12 @@ code objects. Extensions that provide custom statements can return nodes to
execute custom Python code.
The list below describes all nodes that are currently available. The AST may
change between Jinja2 versions but will stay backwards compatible.
change between Jinja versions but will stay backwards compatible.
For more information have a look at the repr of :meth:`jinja2.Environment.parse`.
.. module:: jinja2.nodes
.. jinjanodes::
.. jinja:nodes:: jinja2.nodes.Node
.. autoexception:: Impossible

View File

@ -1,155 +1,77 @@
Frequently Asked Questions
==========================
This page answers some of the often asked questions about Jinja.
.. highlight:: html+jinja
Why is it called Jinja?
-----------------------
The name Jinja was chosen because it's the name of a Japanese temple and
temple and template share a similar pronunciation. It is not named after
the capital city of Uganda.
"Jinja" is a Japanese `Shinto shrine`_, or temple, and temple and
template share a similar English pronunciation. It is not named after
the `city in Uganda`_.
How fast is it?
---------------
.. _Shinto shrine: https://en.wikipedia.org/wiki/Shinto_shrine
.. _city in Uganda: https://en.wikipedia.org/wiki/Jinja%2C_Uganda
We really hate benchmarks especially since they don't reflect much. The
performance of a template depends on many factors and you would have to
benchmark different engines in different situations. The benchmarks from the
testsuite show that Jinja2 has a similar performance to `Mako`_ and is between
10 and 20 times faster than Django's template engine or Genshi. These numbers
should be taken with tons of salt as the benchmarks that took these numbers
only test a few performance related situations such as looping. Generally
speaking the performance of a template engine doesn't matter much as the
usual bottleneck in a web application is either the database or the application
code.
.. _Mako: http://www.makotemplates.org/
How fast is Jinja?
------------------
How Compatible is Jinja2 with Django?
-------------------------------------
Jinja is relatively fast among template engines because it compiles and
caches template code to Python code, so that the template does not need
to be parsed and interpreted each time. Rendering a template becomes as
close to executing a Python function as possible.
The default syntax of Jinja2 matches Django syntax in many ways. However
this similarity doesn't mean that you can use a Django template unmodified
in Jinja2. For example filter arguments use a function call syntax rather
than a colon to separate filter name and arguments. Additionally the
extension interface in Jinja is fundamentally different from the Django one
which means that your custom tags won't work any longer.
Jinja also makes extensive use of caching. Templates are cached by name
after loading, so future uses of the template avoid loading. The
template loading itself uses a bytecode cache to avoid repeated
compiling. The caches can be external to persist across restarts.
Templates can also be precompiled and loaded as fast Python imports.
Generally speaking you will use much less custom extensions as the Jinja
template system allows you to use a certain subset of Python expressions
which can replace most Django extensions. For example instead of using
something like this::
We dislike benchmarks because they don't reflect real use. Performance
depends on many factors. Different engines have different default
configurations and tradeoffs that make it unclear how to set up a useful
comparison. Often, database access, API calls, and data processing have
a much larger effect on performance than the template engine.
{% load comments %}
{% get_latest_comments 10 as latest_comments %}
{% for comment in latest_comments %}
...
{% endfor %}
You will most likely provide an object with attributes to retrieve
comments from the database::
{% for comment in models.comments.latest(10) %}
...
{% endfor %}
Or directly provide the model for quick testing::
{% for comment in Comment.objects.order_by('-pub_date')[:10] %}
...
{% endfor %}
Please keep in mind that even though you may put such things into templates
it still isn't a good idea. Queries should go into the view code and not
the template!
Isn't it a terrible idea to put Logic into Templates?
-----------------------------------------------------
Isn't it a bad idea to put logic in templates?
----------------------------------------------
Without a doubt you should try to remove as much logic from templates as
possible. But templates without any logic mean that you have to do all
the processing in the code which is boring and stupid. A template engine
that does that is shipped with Python and called `string.Template`. Comes
without loops and if conditions and is by far the fastest template engine
you can get for Python.
possible. With less logic, the template is easier to understand, has
fewer potential side effects, and is faster to compile and render. But a
template without any logic means processing must be done in code before
rendering. A template engine that does that is shipped with Python,
called :class:`string.Template`, and while it's definitely fast it's not
convenient.
So some amount of logic is required in templates to keep everyone happy.
And Jinja leaves it pretty much to you how much logic you want to put into
templates. There are some restrictions in what you can do and what not.
Jinja's features such as blocks, statements, filters, and function calls
make it much easier to write expressive templates, with very few
restrictions. Jinja doesn't allow arbitrary Python code in templates, or
every feature available in the Python language. This keeps the engine
easier to maintain, and keeps templates more readable.
Jinja2 neither allows you to put arbitrary Python code into templates nor
does it allow all Python expressions. The operators are limited to the
most common ones and more advanced expressions such as list comprehensions
and generator expressions are not supported. This keeps the template engine
easier to maintain and templates more readable.
Some amount of logic is required in templates to keep everyone happy.
Too much logic in the template can make it complex to reason about and
maintain. It's up to you to decide how your application will work and
balance how much logic you want to put in the template.
Why is Autoescaping not the Default?
------------------------------------
There are multiple reasons why automatic escaping is not the default mode
and also not the recommended one. While automatic escaping of variables
means that you will less likely have an XSS problem it also causes a huge
amount of extra processing in the template engine which can cause serious
performance problems. As Python doesn't provide a way to mark strings as
unsafe Jinja has to hack around that limitation by providing a custom
string class (the :class:`Markup` string) that safely interacts with safe
and unsafe strings.
Why is HTML escaping not the default?
-------------------------------------
With explicit escaping however the template engine doesn't have to perform
any safety checks on variables. Also a human knows not to escape integers
or strings that may never contain characters one has to escape or already
HTML markup. For example when iterating over a list over a table of
integers and floats for a table of statistics the template designer can
omit the escaping because he knows that integers or floats don't contain
any unsafe parameters.
Jinja provides a feature that can be enabled to escape HTML syntax in
rendered templates. However, it is disabled by default.
Additionally Jinja2 is a general purpose template engine and not only used
for HTML/XML generation. For example you may generate LaTeX, emails,
CSS, JavaScript, or configuration files.
Jinja is a general purpose template engine, it is not only used for HTML
documents. You can generate plain text, LaTeX, emails, CSS, JavaScript,
configuration files, etc. HTML escaping wouldn't make sense for any of
these document types.
Why is the Context immutable?
-----------------------------
While automatic escaping means that you are less likely have an XSS
problem, it also requires significant extra processing during compiling
and rendering, which can reduce performance. Jinja uses `MarkupSafe`_ for
escaping, which provides optimized C code for speed, but it still
introduces overhead to track escaping across methods and formatting.
When writing a :func:`contextfunction` or something similar you may have
noticed that the context tries to stop you from modifying it. If you have
managed to modify the context by using an internal context API you may
have noticed that changes in the context don't seem to be visible in the
template. The reason for this is that Jinja uses the context only as
primary data source for template variables for performance reasons.
If you want to modify the context write a function that returns a variable
instead that one can assign to a variable by using set::
{% set comments = get_latest_comments() %}
I don't have the _speedups Module. Is Jinja slower now?
--------------------------------------------------------
To achieve a good performance with automatic escaping enabled, the escaping
function is also implemented in pure C and used if Jinja2 was installed with
the speedups module. This happens automatically if a C compiler is available
on the system during installation.
My tracebacks look weird. What's happening?
--------------------------------------------
If the speedups module is not compiled and you are using a Python installation
without ctypes (Python 2.4 without ctypes, Jython or Google's AppEngine)
Jinja2 is unable to provide correct debugging information and the traceback
may be incomplete. There is currently no good workaround for Jython or
the AppEngine as ctypes is unavailable there and it's not possible to use
the speedups extension.
Why is there no Python 2.3 support?
-----------------------------------
Python 2.3 is missing a lot of features that are used heavily in Jinja2. This
decision was made as with the upcoming Python 2.6 and 3.0 versions it becomes
harder to maintain the code for older Python versions. If you really need
Python 2.3 support you either have to use `Jinja 1`_ or other templating
engines that still support 2.3.
.. _Jinja 1: http://jinja.pocoo.org/1/
.. _MarkupSafe: https://markupsafe.palletsprojects.com/

View File

@ -1,27 +1,29 @@
Jinja2 Documentation
====================
.. rst-class:: hide-header
This is the documentation for the Jinja2 general purpose templating language.
Jinja2 is a library for Python 2.4 and onwards that is designed to be flexible,
fast and secure.
Jinja
=====
.. image:: _static/jinja-name.svg
:align: center
:height: 200px
Jinja is a fast, expressive, extensible templating engine. Special
placeholders in the template allow writing code similar to Python
syntax. Then the template is passed data to render the final document.
.. toctree::
:maxdepth: 2
:maxdepth: 2
:caption: Contents:
intro
api
sandbox
templates
extensions
integration
switching
tricks
faq
changelog
If you can't find the information you're looking for, have a look at the
index of try to find it using the search function:
* :ref:`genindex`
* :ref:`search`
intro
api
sandbox
nativetypes
templates
extensions
integration
switching
tricks
faq
license
changes

View File

@ -1,32 +1,50 @@
Integration
===========
Jinja2 provides some code for integration into other tools such as frameworks,
the `Babel`_ library or your favourite editor for fancy code highlighting.
This is a brief description of whats included.
Flask
-----
The `Flask`_ web application framework, also maintained by Pallets, uses
Jinja templates by default. Flask sets up a Jinja environment and
template loader for you, and provides functions to easily render
templates from view functions.
.. _Flask: https://flask.palletsprojects.com
Django
------
Django supports using Jinja as its template engine, see
https://docs.djangoproject.com/en/stable/topics/templates/#support-for-template-engines.
.. _babel-integration:
Babel Integration
-----------------
Babel
-----
Jinja provides support for extracting gettext messages from templates via a
`Babel`_ extractor entry point called `jinja2.ext.babel_extract`. The Babel
support is implemented as part of the :ref:`i18n-extension` extension.
Jinja provides support for extracting gettext messages from templates
via a `Babel`_ extractor entry point called
``jinja2.ext.babel_extract``. The support is implemented as part of the
:ref:`i18n-extension` extension.
Gettext messages extracted from both `trans` tags and code expressions.
Gettext messages are extracted from both ``trans`` tags and code
expressions.
To extract gettext messages from templates, the project needs a Jinja2 section
in its Babel extraction method `mapping file`_:
To extract gettext messages from templates, the project needs a Jinja
section in its Babel extraction method `mapping file`_:
.. sourcecode:: ini
[jinja2: **/templates/**.html]
encoding = utf-8
The syntax related options of the :class:`Environment` are also available as
configuration values in the mapping file. For example to tell the extraction
that templates use ``%`` as `line_statement_prefix` you can use this code:
The syntax related options of the :class:`Environment` are also
available as configuration values in the mapping file. For example, to
tell the extractor that templates use ``%`` as
``line_statement_prefix`` you can use this code:
.. sourcecode:: ini
@ -34,55 +52,43 @@ that templates use ``%`` as `line_statement_prefix` you can use this code:
encoding = utf-8
line_statement_prefix = %
:ref:`jinja-extensions` may also be defined by passing a comma separated list
of import paths as `extensions` value. The i18n extension is added
automatically.
:ref:`jinja-extensions` may also be defined by passing a comma separated
list of import paths as the ``extensions`` value. The i18n extension is
added automatically.
Template syntax errors are ignored by default. The assumption is that
tests will catch syntax errors in templates. If you don't want to ignore
errors, add ``silent = false`` to the settings.
.. _Babel: https://babel.readthedocs.io/
.. _mapping file: https://babel.readthedocs.io/en/latest/messages.html#extraction-method-mapping-and-configuration
.. _mapping file: http://babel.edgewall.org/wiki/Documentation/messages.html#extraction-method-mapping-and-configuration
Pylons
------
With `Pylons`_ 0.9.7 onwards it's incredible easy to integrate Jinja into a
Pylons powered application.
It's easy to integrate Jinja into a `Pylons`_ application.
The template engine is configured in `config/environment.py`. The configuration
for Jinja2 looks something like that::
The template engine is configured in ``config/environment.py``. The
configuration for Jinja looks something like this:
.. code-block:: python
from jinja2 import Environment, PackageLoader
config['pylons.app_globals'].jinja_env = Environment(
loader=PackageLoader('yourapplication', 'templates')
)
After that you can render Jinja templates by using the `render_jinja` function
from the `pylons.templating` module.
After that you can render Jinja templates by using the ``render_jinja``
function from the ``pylons.templating`` module.
Additionally it's a good idea to set the Pylons' `c` object into strict mode.
Per default any attribute to not existing attributes on the `c` object return
an empty string and not an undefined object. To change this just use this
snippet and add it into your `config/environment.py`::
Additionally it's a good idea to set the Pylons ``c`` object to strict
mode. By default attribute access on missing attributes on the ``c``
object returns an empty string and not an undefined object. To change
this add this to ``config/environment.py``:
.. code-block:: python
config['pylons.strict_c'] = True
.. _Pylons: http://www.pylonshq.com/
TextMate
--------
Inside the `ext` folder of Jinja2 there is a bundle for TextMate that supports
syntax highlighting for Jinja1 and Jinja2 for text based templates as well as
HTML. It also contains a few often used snippets.
Vim
---
A syntax plugin for `Vim`_ exists in the Vim-scripts directory as well as the
ext folder of Jinja2. `The script <http://www.vim.org/scripts/script.php?script_id=1856>`_
supports Jinja1 and Jinja2. Once installed two file types are available `jinja`
and `htmljinja`. The first one for text based templates, the latter for HTML
templates.
Copy the files into your `syntax` folder.
.. _Babel: http://babel.edgewall.org/
.. _Vim: http://www.vim.org/
.. _Pylons: https://pylonsproject.org/

View File

@ -1,156 +1,63 @@
Introduction
============
This is the documentation for the Jinja2 general purpose templating language.
Jinja2 is a library for Python 2.4 and onwards that is designed to be flexible,
fast and secure.
Jinja is a fast, expressive, extensible templating engine. Special
placeholders in the template allow writing code similar to Python
syntax. Then the template is passed data to render the final document.
If you have any exposure to other text-based template languages, such as Smarty or
Django, you should feel right at home with Jinja2. It's both designer and
developer friendly by sticking to Python's principles and adding functionality
useful for templating environments.
It includes:
The key-features are...
- Template inheritance and inclusion.
- Define and import macros within templates.
- HTML templates can use autoescaping to prevent XSS from untrusted
user input.
- A sandboxed environment can safely render untrusted templates.
- Async support for generating templates that automatically handle
sync and async functions without extra syntax.
- I18N support with Babel.
- Templates are compiled to optimized Python code just-in-time and
cached, or can be compiled ahead-of-time.
- Exceptions point to the correct line in templates to make debugging
easier.
- Extensible filters, tests, functions, and even syntax.
- ... **configurable syntax**. If you are generating LaTeX or other formats
with Jinja2 you can change the delimiters to something that integrates better
into the LaTeX markup.
- ... **fast**. While performance is not the primarily target of Jinja2 it's
surprisingly fast. The overhead compared to regular Python code was reduced
to the very minimum.
- ... **easy to debug**. Jinja2 integrates directly into the python traceback
system which allows you to debug Jinja2 templates with regular python
debugging helpers.
- ... **secure**. It's possible to evaluate untrusted template code if the
optional sandbox is enabled. This allows Jinja2 to be used as templating
language for applications where users may modify the template design.
Prerequisites
-------------
Jinja2 needs at least **Python 2.4** to run. Additionally a working C-compiler
that can create python extensions should be installed for the debugger. If no
C-compiler is available and you are using Python 2.4 the `ctypes`_ module
should be installed.
If you don't have a working C compiler and you are trying to install the source
release with the speedups you will get a compiler error. This however can be
circumvented by passing the ``--without-speedups`` command line argument to the
setup script::
$ python setup.py install --with-speedups
(As of Jinja 2.2, the speedups are disabled by default and can be enabled
with ``--with-speedups``. See :ref:`enable-speedups`)
.. _ctypes: http://python.net/crew/theller/ctypes/
Jinja's philosophy is that while application logic belongs in Python if
possible, it shouldn't make the template designer's job difficult by
restricting functionality too much.
Installation
------------
You have multiple ways to install Jinja2. If you are unsure what to do, go
with the Python egg or tarball.
We recommend using the latest version of Python. Jinja supports Python
3.10 and newer. We also recommend using a `virtual environment`_ in order
to isolate your project dependencies from other projects and the system.
As a Python egg (via easy_install)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. _virtual environment: https://packaging.python.org/tutorials/installing-packages/#creating-virtual-environments
You can install the most recent Jinja2 version using `easy_install`_ or `pip`_::
Install the most recent Jinja version using pip:
easy_install Jinja2
pip install Jinja2
.. code-block:: text
This will install a Jinja2 egg in your Python installation's site-packages
directory.
(If you are installing from the windows command line omit the `sudo` and make
sure to run the command as user with administrator rights)
From the tarball release
~~~~~~~~~~~~~~~~~~~~~~~~~
1. Download the most recent tarball from the `download page`_
2. Unpack the tarball
3. ``sudo python setup.py install``
Note that the last command will automatically download and install
`setuptools`_ if you don't already have it installed. This requires a working
internet connection.
This will install Jinja2 into your Python installation's site-packages directory.
Installing the development version
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1. Install `mercurial`_
2. ``hg clone http://dev.pocoo.org/hg/jinja2-main jinja2``
3. ``cd jinja2``
4. ``ln -s jinja2 /usr/lib/python2.X/site-packages``
As an alternative to steps 4 you can also do ``python setup.py develop``
which will install the package via setuptools in development mode. This also
has the advantage that the C extensions are compiled.
Alternative you can use `easy_install`_ to install the current development
snapshot::
sudo easy_install Jinja2==dev
Or the new `pip`_ command::
sudo pip install Jinja2==dev
.. _download page: http://pypi.python.org/pypi/Jinja2
.. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools
.. _easy_install: http://peak.telecommunity.com/DevCenter/EasyInstall
.. _pip: http://pypi.python.org/pypi/pip
.. _mercurial: http://www.selenic.com/mercurial/
.. _enable-speedups:
Enaable the speedups Module
~~~~~~~~~~~~~~~~~~~~~~~~~~~
By default Jinja2 will not compile the speedups module. Enabling this
will fail if you don't have the Python headers or a working compiler. This
is often the case if you are installing Jinja2 from a windows machine.
You can enable the speedups extension when installing using the
``--with-speedups`` flag::
sudo python setup.py install --with-speedups
You can also pass this parameter to `pip`::
$ pip install --install-option='--with-speedups' Jinja2
$ pip install Jinja2
Basic API Usage
---------------
Dependencies
~~~~~~~~~~~~
This section gives you a brief introduction to the Python API for Jinja2
templates.
These will be installed automatically when installing Jinja.
The most basic way to create a template and render it is through
:class:`~jinja2.Template`. This however is not the recommended way to
work with it if your templates are not loaded from strings but the file
system or another data source:
- `MarkupSafe`_ escapes untrusted input when rendering templates to
avoid injection attacks.
>>> from jinja2 import Template
>>> template = Template('Hello {{ name }}!')
>>> template.render(name='John Doe')
u'Hello John Doe!'
.. _MarkupSafe: https://markupsafe.palletsprojects.com/
By creating an instance of :class:`~jinja2.Template` you get back a new template
object that provides a method called :meth:`~jinja2.Template.render` which when
called with a dict or keyword arguments expands the template. The dict
or keywords arguments passed to the template are the so-called "context"
of the template.
What you can see here is that Jinja2 is using unicode internally and the
return value is an unicode string. So make sure that your application is
indeed using unicode internally.
Optional Dependencies
~~~~~~~~~~~~~~~~~~~~~
These distributions will not be installed automatically.
- `Babel`_ provides translation support in templates.
.. _Babel: https://babel.pocoo.org/

View File

@ -1,192 +0,0 @@
# -*- coding: utf-8 -*-
"""
Jinja Documentation Extensions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for automatically documenting filters and tests.
:copyright: Copyright 2008 by Armin Ronacher.
:license: BSD.
"""
import os
import re
import inspect
import jinja2
from itertools import islice
from types import BuiltinFunctionType
from docutils import nodes
from docutils.statemachine import ViewList
from sphinx.ext.autodoc import prepare_docstring
from sphinx.application import TemplateBridge
from pygments.style import Style
from pygments.token import Keyword, Name, Comment, String, Error, \
Number, Operator, Generic
from jinja2 import Environment, FileSystemLoader
def parse_rst(state, content_offset, doc):
node = nodes.section()
# hack around title style bookkeeping
surrounding_title_styles = state.memo.title_styles
surrounding_section_level = state.memo.section_level
state.memo.title_styles = []
state.memo.section_level = 0
state.nested_parse(doc, content_offset, node, match_titles=1)
state.memo.title_styles = surrounding_title_styles
state.memo.section_level = surrounding_section_level
return node.children
class JinjaStyle(Style):
title = 'Jinja Style'
default_style = ""
styles = {
Comment: 'italic #aaaaaa',
Comment.Preproc: 'noitalic #B11414',
Comment.Special: 'italic #505050',
Keyword: 'bold #B80000',
Keyword.Type: '#808080',
Operator.Word: 'bold #B80000',
Name.Builtin: '#333333',
Name.Function: '#333333',
Name.Class: 'bold #333333',
Name.Namespace: 'bold #333333',
Name.Entity: 'bold #363636',
Name.Attribute: '#686868',
Name.Tag: 'bold #686868',
Name.Decorator: '#686868',
String: '#AA891C',
Number: '#444444',
Generic.Heading: 'bold #000080',
Generic.Subheading: 'bold #800080',
Generic.Deleted: '#aa0000',
Generic.Inserted: '#00aa00',
Generic.Error: '#aa0000',
Generic.Emph: 'italic',
Generic.Strong: 'bold',
Generic.Prompt: '#555555',
Generic.Output: '#888888',
Generic.Traceback: '#aa0000',
Error: '#F00 bg:#FAA'
}
_sig_re = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*(\(.*?\))')
def format_function(name, aliases, func):
lines = inspect.getdoc(func).splitlines()
signature = '()'
if isinstance(func, BuiltinFunctionType):
match = _sig_re.match(lines[0])
if match is not None:
del lines[:1 + bool(lines and not lines[0])]
signature = match.group(1)
else:
try:
argspec = inspect.getargspec(func)
if getattr(func, 'environmentfilter', False) or \
getattr(func, 'contextfilter', False):
del argspec[0][0]
signature = inspect.formatargspec(*argspec)
except:
pass
result = ['.. function:: %s%s' % (name, signature), '']
result.extend(' ' + line for line in lines)
if aliases:
result.extend(('', ' :aliases: %s' % ', '.join(
'``%s``' % x for x in sorted(aliases))))
return result
def dump_functions(mapping):
def directive(dirname, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
reverse_mapping = {}
for name, func in mapping.iteritems():
reverse_mapping.setdefault(func, []).append(name)
filters = []
for func, names in reverse_mapping.iteritems():
aliases = sorted(names, key=lambda x: len(x))
name = aliases.pop()
filters.append((name, aliases, func))
filters.sort()
result = ViewList()
for name, aliases, func in filters:
for item in format_function(name, aliases, func):
result.append(item, '<jinjaext>')
node = nodes.paragraph()
state.nested_parse(result, content_offset, node)
return node.children
return directive
from jinja2.defaults import DEFAULT_FILTERS, DEFAULT_TESTS
jinja_filters = dump_functions(DEFAULT_FILTERS)
jinja_tests = dump_functions(DEFAULT_TESTS)
def jinja_nodes(dirname, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
from jinja2.nodes import Node
doc = ViewList()
def walk(node, indent):
p = ' ' * indent
sig = ', '.join(node.fields)
doc.append(p + '.. autoclass:: %s(%s)' % (node.__name__, sig), '')
if node.abstract:
members = []
for key, name in node.__dict__.iteritems():
if not key.startswith('_') and \
not hasattr(node.__base__, key) and callable(name):
members.append(key)
if members:
members.sort()
doc.append('%s :members: %s' % (p, ', '.join(members)), '')
if node.__base__ != object:
doc.append('', '')
doc.append('%s :Node type: :class:`%s`' %
(p, node.__base__.__name__), '')
doc.append('', '')
children = node.__subclasses__()
children.sort(key=lambda x: x.__name__.lower())
for child in children:
walk(child, indent)
walk(Node, 0)
return parse_rst(state, content_offset, doc)
def inject_toc(app, doctree, docname):
titleiter = iter(doctree.traverse(nodes.title))
try:
# skip first title, we are not interested in that one
titleiter.next()
title = titleiter.next()
# and check if there is at least another title
titleiter.next()
except StopIteration:
return
tocnode = nodes.section('')
tocnode['classes'].append('toc')
toctitle = nodes.section('')
toctitle['classes'].append('toctitle')
toctitle.append(nodes.title(text='Table Of Contents'))
tocnode.append(toctitle)
tocnode += doctree.document.settings.env.get_toc_for(docname)[0][1]
title.parent.insert(title.parent.children.index(title), tocnode)
def setup(app):
app.add_directive('jinjafilters', jinja_filters, 0, (0, 0, 0))
app.add_directive('jinjatests', jinja_tests, 0, (0, 0, 0))
app.add_directive('jinjanodes', jinja_nodes, 0, (0, 0, 0))
# uncomment for inline toc. links are broken unfortunately
##app.connect('doctree-resolved', inject_toc)

5
docs/license.rst Normal file
View File

@ -0,0 +1,5 @@
BSD-3-Clause License
====================
.. literalinclude:: ../LICENSE.txt
:language: text

35
docs/make.bat Normal file
View File

@ -0,0 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
:end
popd

75
docs/nativetypes.rst Normal file
View File

@ -0,0 +1,75 @@
.. module:: jinja2.nativetypes
.. _nativetypes:
Native Python Types
===================
The default :class:`~jinja2.Environment` renders templates to strings. With
:class:`NativeEnvironment`, rendering a template produces a native Python type.
This is useful if you are using Jinja outside the context of creating text
files. For example, your code may have an intermediate step where users may use
templates to define values that will then be passed to a traditional string
environment.
Examples
--------
Adding two values results in an integer, not a string with a number:
>>> env = NativeEnvironment()
>>> t = env.from_string('{{ x + y }}')
>>> result = t.render(x=4, y=2)
>>> print(result)
6
>>> print(type(result))
int
Rendering list syntax produces a list:
>>> t = env.from_string('[{% for item in data %}{{ item + 1 }},{% endfor %}]')
>>> result = t.render(data=range(5))
>>> print(result)
[1, 2, 3, 4, 5]
>>> print(type(result))
list
Rendering something that doesn't look like a Python literal produces a string:
>>> t = env.from_string('{{ x }} * {{ y }}')
>>> result = t.render(x=4, y=2)
>>> print(result)
4 * 2
>>> print(type(result))
str
Rendering a Python object produces that object as long as it is the only node:
>>> class Foo:
... def __init__(self, value):
... self.value = value
...
>>> result = env.from_string('{{ x }}').render(x=Foo(15))
>>> print(type(result).__name__)
Foo
>>> print(result.value)
15
Sandboxed Native Environment
----------------------------
You can combine :class:`.SandboxedEnvironment` and :class:`NativeEnvironment` to
get both behaviors.
.. code-block:: python
class SandboxedNativeEnvironment(SandboxedEnvironment, NativeEnvironment):
pass
API
---
.. autoclass:: NativeEnvironment([options])
.. autoclass:: NativeTemplate([options])
:members: render

View File

@ -1,24 +1,66 @@
Sandbox
=======
The Jinja2 sandbox can be used to evaluate untrusted code. Access to unsafe
attributes and methods is prohibited.
The Jinja sandbox can be used to render untrusted templates. Access to
attributes, method calls, operators, mutating data structures, and
string formatting can be intercepted and prohibited.
Assuming `env` is a :class:`SandboxedEnvironment` in the default configuration
the following piece of code shows how it works:
.. code-block:: pycon
>>> env.from_string("{{ func.func_code }}").render(func=lambda:None)
u''
>>> env.from_string("{{ func.func_code.do_something }}").render(func=lambda:None)
Traceback (most recent call last):
...
SecurityError: access to attribute 'func_code' of 'function' object is unsafe.
>>> from jinja2.sandbox import SandboxedEnvironment
>>> env = SandboxedEnvironment()
>>> func = lambda: "Hello, Sandbox!"
>>> env.from_string("{{ func() }}").render(func=func)
'Hello, Sandbox!'
>>> env.from_string("{{ func.__code__.co_code }}").render(func=func)
Traceback (most recent call last):
...
SecurityError: access to attribute '__code__' of 'function' object is unsafe.
A sandboxed environment can be useful, for example, to allow users of an
internal reporting system to create custom emails. You would document
what data is available in the templates, then the user would write a
template using that information. Your code would generate the report
data and pass it to the user's sandboxed template to render.
Security Considerations
-----------------------
The sandbox alone is not a solution for perfect security. Keep these
things in mind when using the sandbox.
Templates can still raise errors when compiled or rendered. Your code
should attempt to catch errors instead of crashing.
It is possible to construct a relatively small template that renders to
a very large amount of output, which could correspond to a high use of
CPU or memory. You should run your application with limits on resources
such as CPU and memory to mitigate this.
Jinja only renders text, it does not understand, for example, JavaScript
code. Depending on how the rendered template will be used, you may need
to do other postprocessing to restrict the output.
Pass only the data that is relevant to the template. Avoid passing
global data, or objects with methods that have side effects. By default
the sandbox prevents private and internal attribute access. You can
override :meth:`~SandboxedEnvironment.is_safe_attribute` to further
restrict attributes access. Decorate methods with :func:`unsafe` to
prevent calling them from templates when passing objects as data. Use
:class:`ImmutableSandboxedEnvironment` to prevent modifying lists and
dictionaries.
API
---
.. module:: jinja2.sandbox
.. autoclass:: SandboxedEnvironment([options])
:members: is_safe_attribute, is_safe_callable
:members: is_safe_attribute, is_safe_callable, default_binop_table,
default_unop_table, intercepted_binops, intercepted_unops,
call_binop, call_unop
.. autoclass:: ImmutableSandboxedEnvironment([options])
@ -30,17 +72,40 @@ SecurityError: access to attribute 'func_code' of 'function' object is unsafe.
.. autofunction:: modifies_known_mutable
.. admonition:: Note
The Jinja2 sandbox alone is no solution for perfect security. Especially
for web applications you have to keep in mind that users may create
templates with arbitrary HTML in so it's crucial to ensure that (if you
are running multiple users on the same server) they can't harm each other
via JavaScript insertions and much more.
Operator Intercepting
---------------------
Also the sandbox is only as good as the configuration. We stronly
recommend only passing non-shared resources to the template and use
some sort of whitelisting for attributes.
For performance, Jinja outputs operators directly when compiling. This
means it's not possible to intercept operator behavior by overriding
:meth:`SandboxEnvironment.call <Environment.call>` by default, because
operator special methods are handled by the Python interpreter, and
might not correspond with exactly one method depending on the operator's
use.
Also keep in mind that templates may raise runtime or compile time errors,
so make sure to catch them.
The sandbox can instruct the compiler to output a function to intercept
certain operators instead. Override
:attr:`SandboxedEnvironment.intercepted_binops` and
:attr:`SandboxedEnvironment.intercepted_unops` with the operator symbols
you want to intercept. The compiler will replace the symbols with calls
to :meth:`SandboxedEnvironment.call_binop` and
:meth:`SandboxedEnvironment.call_unop` instead. The default
implementation of those methods will use
:attr:`SandboxedEnvironment.binop_table` and
:attr:`SandboxedEnvironment.unop_table` to translate operator symbols
into :mod:`operator` functions.
For example, the power (``**``) operator can be disabled:
.. code-block:: python
from jinja2.sandbox import SandboxedEnvironment
class MyEnvironment(SandboxedEnvironment):
intercepted_binops = frozenset(["**"])
def call_binop(self, context, operator, left, right):
if operator == "**":
return self.undefined("The power (**) operator is unavailable.")
return super().call_binop(self, context, operator, left, right)

View File

@ -1,172 +1,73 @@
Switching from other Template Engines
Switching From Other Template Engines
=====================================
.. highlight:: html+jinja
If you have used a different template engine in the past and want to swtich
to Jinja2 here is a small guide that shows the basic syntatic and semantic
changes between some common, similar text template engines for Python.
Jinja1
------
Jinja2 is mostly compatible with Jinja1 in terms of API usage and template
syntax. The differences between Jinja1 and 2 are explained in the following
list.
API
~~~
Loaders
Jinja2 uses a different loader API. Because the internal representation
of templates changed there is no longer support for external caching
systems such as memcached. The memory consumed by templates is comparable
with regular Python modules now and external caching doesn't give any
advantage. If you have used a custom loader in the past have a look at
the new :ref:`loader API <loaders>`.
Loading templates from strings
In the past it was possible to generate templates from a string with the
default environment configuration by using `jinja.from_string`. Jinja2
provides a :class:`Template` class that can be used to do the same, but
with optional additional configuration.
Automatic unicode conversion
Jinja1 performed automatic conversion of bytestrings in a given encoding
into unicode objects. This conversion is no longer implemented as it
was inconsistent as most libraries are using the regular Python ASCII
bytestring to Unicode conversion. An application powered by Jinja2
*has to* use unicode internally everywhere or make sure that Jinja2 only
gets unicode strings passed.
i18n
Jinja1 used custom translators for internationalization. i18n is now
available as Jinja2 extension and uses a simpler, more gettext friendly
interface and has support for babel. For more details see
:ref:`i18n-extension`.
Internal methods
Jinja1 exposed a few internal methods on the environment object such
as `call_function`, `get_attribute` and others. While they were marked
as being an internal method it was possible to override them. Jinja2
doesn't have equivalent methods.
Sandbox
Jinja1 was running sandbox mode by default. Few applications actually
used that feature so it became optional in Jinja2. For more details
about the sandboxed execution see :class:`SandboxedEnvironment`.
Context
Jinja1 had a stacked context as storage for variables passed to the
environment. In Jinja2 a similar object exists but it doesn't allow
modifications nor is it a singleton. As inheritance is dynamic now
multiple context objects may exist during template evaluation.
Filters and Tests
Filters and tests are regular functions now. It's no longer necessary
and allowed to use factory functions.
Templates
~~~~~~~~~
Jinja2 has mostly the same syntax as Jinja1. What's different is that
macros require parentheses around the argument list now.
Additionally Jinja2 allows dynamic inheritance now and dynamic includes.
The old helper function `rendertemplate` is gone now, `include` can be used
instead. Includes no longer import macros and variable assignments, for
that the new `import` tag is used. This concept is explained in the
:ref:`import` documentation.
Another small change happened in the `for`-tag. The special loop variable
doesn't have a `parent` attribute, instead you have to alias the loop
yourself. See :ref:`accessing-the-parent-loop` for more details.
This is a brief guide on some of the differences between Jinja syntax
and other template languages. See :doc:`/templates` for a comprehensive
guide to Jinja syntax and features.
Django
------
If you have previously worked with Django templates, you should find
Jinja2 very familiar. In fact, most of the syntax elements look and
work the same.
Jinja very familiar. Many of the syntax elements look and work the same.
However, Jinja provides some more syntax elements, and some work a bit
differently.
However, Jinja2 provides some more syntax elements covered in the
documentation and some work a bit different.
This section covers the template changes. The API, including extension
support, is fundamentally different so it won't be covered here.
Django supports using Jinja as its template engine, see
https://docs.djangoproject.com/en/stable/topics/templates/#support-for-template-engines.
This section covers the template changes. As the API is fundamentally
different we won't cover it here.
Method Calls
~~~~~~~~~~~~
In Django method calls work implicitly. With Jinja2 you have to specify that
you want to call an object. Thus this Django code::
In Django, methods are called implicitly, without parentheses.
.. code-block:: django
{% for page in user.get_created_pages %}
...
{% endfor %}
will look like this in Jinja::
In Jinja, using parentheses is required for calls, like in Python. This
allows you to pass variables to the method, which is not possible
in Django. This syntax is also used for calling macros.
.. code-block:: jinja
{% for page in user.get_created_pages() %}
...
{% endfor %}
This allows you to pass variables to the function which is also used for macros
which is not possible in Django.
Conditions
~~~~~~~~~~
In Django you can use the following constructs to check for equality::
{% ifequal foo "bar" %}
...
{% else %}
...
{% endifequal %}
In Jinja2 you can use the normal if statement in combination with operators::
{% if foo == 'bar' %}
...
{% else %}
...
{% endif %}
You can also have multiple elif branches in your template::
{% if something %}
...
{% elif otherthing %}
...
{% elif foothing %}
...
{% else %}
...
{% endif %}
Filter Arguments
~~~~~~~~~~~~~~~~
Jinja2 provides more than one argument for filters. Also the syntax for
argument passing is different. A template that looks like this in Django::
In Django, one literal value can be passed to a filter after a colon.
.. code-block:: django
{{ items|join:", " }}
looks like this in Jinja2::
In Jinja, filters can take any number of positional and keyword
arguments in parentheses, like function calls. Arguments can also be
variables instead of literal values.
{{ items|join(', ') }}
.. code-block:: jinja
{{ items|join(", ") }}
In fact it's a bit more verbose but it allows different types of arguments -
including variables - and more than one of them.
Tests
~~~~~
In addition to filters there also are tests you can perform using the is
operator. Here are some examples::
In addition to filters, Jinja also has "tests" used with the ``is``
operator. This operator is not the same as the Python operator.
.. code-block:: jinja
{% if user.user_id is odd %}
{{ user.username|e }} is odd
@ -177,49 +78,85 @@ operator. Here are some examples::
Loops
~~~~~
For loops work very similar to Django, the only incompatibility is that in
Jinja2 the special variable for the loop context is called `loop` and not
`forloop` like in Django.
In Django, the special variable for the loop context is called
``forloop``, and the ``empty`` is used for no loop items.
.. code-block:: django
{% for item in items %}
{{ forloop.counter }}. {{ item }}
{% empty %}
No items!
{% endfor %}
In Jinja, the special variable for the loop context is called ``loop``,
and the ``else`` block is used for no loop items.
.. code-block:: jinja
{% for item in items %}
{{ loop.index }}. {{ item }}
{% else %}
No items!
{% endfor %}
Cycle
~~~~~
The ``{% cycle %}`` tag does not exist in Jinja because of it's implicit
nature. However you can achieve mostly the same by using the `cycle`
method on a loop object.
In Django, the ``{% cycle %}`` can be used in a for loop to alternate
between values per loop.
The following Django template::
.. code-block:: django
{% for user in users %}
<li class="{% cycle 'odd' 'even' %}">{{ user }}</li>
{% endfor %}
Would look like this in Jinja::
In Jinja, the ``loop`` context has a ``cycle`` method.
.. code-block:: jinja
{% for user in users %}
<li class="{{ loop.cycle('odd', 'even') }}">{{ user }}</li>
{% endfor %}
There is no equivalent of ``{% cycle ... as variable %}``.
A cycler can also be assigned to a variable and used outside or across
loops with the ``cycle()`` global function.
Mako
----
.. highlight:: html+mako
You can configure Jinja to look more like Mako:
If you have used Mako so far and want to switch to Jinja2 you can configure
Jinja2 to look more like Mako:
.. code-block:: python
.. sourcecode:: python
env = Environment(
block_start_string="<%",
block_end_string="%>",
variable_start_string="${",
variable_end_string="}",
comment_start_string="<%doc>",
commend_end_string="</%doc>",
line_statement_prefix="%",
line_comment_prefix="##",
)
env = Environment('<%', '%>', '${', '}', '%')
With an environment configured like that, Jinja should be able to
interpret a small subset of Mako templates without any changes.
Once the environment is configure like that Jinja2 should be able to interpret
a small subset of Mako templates. Jinja2 does not support embedded Python code
so you would have to move that out of the template. The syntax for defs (in
Jinja2 defs are called macros) and template inheritance is different too. The
following Mako template::
Jinja does not support embedded Python code, so you would have to move
that out of the template. You could either process the data with the
same code before rendering, or add a global function or filter to the
Jinja environment.
The syntax for defs (which are called macros in Jinja) and template
inheritance is different too.
The following Mako template:
.. code-block:: mako
<%inherit file="layout.html" />
<%def name="title()">Page Title</%def>
@ -229,7 +166,9 @@ following Mako template::
% endfor
</ul>
Looks like this in Jinja2 with the above configuration::
Looks like this in Jinja with the above configuration:
.. code-block:: jinja
<% extends "layout.html" %>
<% block title %>Page Title<% endblock %>

File diff suppressed because it is too large Load Diff

View File

@ -3,30 +3,30 @@ Tips and Tricks
.. highlight:: html+jinja
This part of the documentation shows some tips and tricks for Jinja2
This part of the documentation shows some tips and tricks for Jinja
templates.
.. _null-master-fallback:
.. _null-default-fallback:
Null-Master Fallback
--------------------
Null-Default Fallback
---------------------
Jinja2 supports dynamic inheritance and does not distinguish between parent
Jinja supports dynamic inheritance and does not distinguish between parent
and child template as long as no `extends` tag is visited. While this leads
to the surprising behavior that everything before the first `extends` tag
including whitespace is printed out instead of being igored, it can be used
including whitespace is printed out instead of being ignored, it can be used
for a neat trick.
Usually child templates extend from one template that adds a basic HTML
skeleton. However it's possible put the `extends` tag into an `if` tag to
skeleton. However it's possible to put the `extends` tag into an `if` tag to
only extend from the layout template if the `standalone` variable evaluates
to false which it does per default if it's not defined. Additionally a very
to false, which it does by default if it's not defined. Additionally a very
basic skeleton is added to the file so that if it's indeed rendered with
`standalone` set to `True` a very basic HTML skeleton is added::
{% if not standalone %}{% extends 'master.html' %}{% endif -%}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
{% if not standalone %}{% extends 'default.html' %}{% endif -%}
<!DOCTYPE html>
<title>{% block title %}The Page Title{% endblock %}</title>
<link rel="stylesheet" href="style.css" type="text/css">
{% block body %}
@ -46,7 +46,7 @@ list you can use the `cycle` method on the `loop` object::
{% endfor %}
</ul>
`cycle` can take an unlimited amount of strings. Each time this
`cycle` can take an unlimited number of strings. Each time this
tag is encountered the next item from the list is rendered.
@ -63,7 +63,7 @@ child template::
{% set active_page = "index" %}
The layout template can then access `active_page`. Additionally it makes
sense to defined a default for that variable::
sense to define a default for that variable::
{% set navigation_bar = [
('/', 'index', 'Index'),
@ -74,8 +74,8 @@ sense to defined a default for that variable::
...
<ul id="navigation">
{% for href, id, caption in navigation_bar %}
<li{% if id == active_page %} class="active"{% endif
%}><a href="{{ href|e }}">{{ caption|e }}</a>/li>
<li{% if id == active_page %} class="active"{% endif %}>
<a href="{{ href|e }}">{{ caption|e }}</a></li>
{% endfor %}
</ul>
...
@ -93,7 +93,7 @@ desired to have access to an outer loop it's possible to alias it::
<tr>
{% set rowloop = loop %}
{% for cell in row %}
<td id="cell-{{ rowloop.index }}-{{ loop.index }}>{{ cell }}</td>
<td id="cell-{{ rowloop.index }}-{{ loop.index }}">{{ cell }}</td>
{% endfor %}
</tr>
{% endfor %}

View File

@ -1,13 +1,16 @@
from jinja2 import Environment
env = Environment(line_statement_prefix="#", variable_start_string="${", variable_end_string="}")
print env.from_string("""\
env = Environment(
line_statement_prefix="#", variable_start_string="${", variable_end_string="}"
)
print(
env.from_string(
"""\
<ul>
# for item in range(10)
<li class="${loop.cycle('odd', 'even')}">${item}</li>
# endfor
</ul>\
""").render()
"""
).render()
)

View File

@ -1,7 +1,6 @@
from jinja2 import Environment
from jinja2.loaders import FileSystemLoader
env = Environment(loader=FileSystemLoader('templates'))
tmpl = env.get_template('broken.html')
print tmpl.render(seq=[3, 2, 4, 5, 3, 2, 0, 2, 1])
env = Environment(loader=FileSystemLoader("templates"))
tmpl = env.get_template("broken.html")
print(tmpl.render(seq=[3, 2, 4, 5, 3, 2, 0, 2, 1]))

View File

@ -1,12 +1,13 @@
from jinja2 import Environment
from jinja2.loaders import DictLoader
env = Environment(loader=DictLoader({
'a': '''[A[{% block body %}{% endblock %}]]''',
'b': '''{% extends 'a' %}{% block body %}[B]{% endblock %}''',
'c': '''{% extends 'b' %}{% block body %}###{{ super() }}###{% endblock %}'''
}))
print env.get_template('c').render()
env = Environment(
loader=DictLoader(
{
"a": "[A[{% block body %}{% endblock %}]]",
"b": "{% extends 'a' %}{% block body %}[B]{% endblock %}",
"c": "{% extends 'b' %}{% block body %}###{{ super() }}###{% endblock %}",
}
)
)
print(env.get_template("c").render())

View File

@ -1,27 +1,29 @@
from jinja2 import Environment
from jinja2.loaders import DictLoader
env = Environment(loader=DictLoader({
'child.html': u'''\
{% extends master_layout or 'master.html' %}
{% include helpers = 'helpers.html' %}
env = Environment(
loader=DictLoader(
{
"child.html": """\
{% extends default_layout or 'default.html' %}
{% import 'helpers.html' as helpers %}
{% macro get_the_answer() %}42{% endmacro %}
{% title = 'Hello World' %}
{% set title = 'Hello World' %}
{% block body %}
{{ get_the_answer() }}
{{ helpers.conspirate() }}
{% endblock %}
''',
'master.html': u'''\
""",
"default.html": """\
<!doctype html>
<title>{{ title }}</title>
{% block body %}{% endblock %}
''',
'helpers.html': u'''\
""",
"helpers.html": """\
{% macro conspirate() %}23{% endmacro %}
'''
}))
""",
}
)
)
tmpl = env.get_template("child.html")
print tmpl.render()
print(tmpl.render())

View File

@ -1,8 +1,10 @@
from jinja2 import Environment
env = Environment(line_statement_prefix='%', variable_start_string="${", variable_end_string="}")
tmpl = env.from_string("""\
env = Environment(
line_statement_prefix="%", variable_start_string="${", variable_end_string="}"
)
tmpl = env.from_string(
"""\
% macro foo()
${caller(42)}
% endmacro
@ -20,6 +22,6 @@ tmpl = env.from_string("""\
- ${item}
% endfor
% endfilter
""")
print tmpl.render(seq=range(10))
"""
)
print(tmpl.render(seq=range(10)))

View File

@ -1,12 +1,13 @@
from jinja2 import Environment
tmpl = Environment().from_string("""\
tmpl = Environment().from_string(
"""\
<ul>
{%- for item in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] if item % 2 == 0 %}
<li>{{ loop.index }} / {{ loop.length }}: {{ item }}</li>
{%- endfor %}
</ul>
if condition: {{ 1 if foo else 0 }}
""")
print tmpl.render(foo=True)
"""
)
print(tmpl.render(foo=True))

View File

@ -1,6 +1,18 @@
from jinja2 import Environment
print Environment(extensions=['jinja2.i18n.TransExtension']).from_string("""\
env = Environment(extensions=["jinja2.ext.i18n"])
env.globals["gettext"] = {"Hello %(user)s!": "Hallo %(user)s!"}.__getitem__
env.globals["ngettext"] = lambda s, p, n: {
"%(count)s user": "%(count)d Benutzer",
"%(count)s users": "%(count)d Benutzer",
}[s if n == 1 else p]
print(
env.from_string(
"""\
{% trans %}Hello {{ user }}!{% endtrans %}
{% trans count=users|count %}{{ count }} user{% pluralize %}{{ count }} users{% endtrans %}
""").render(user="someone")
{% trans count=users|count -%}
{{ count }} user{% pluralize %}{{ count }} users
{% endtrans %}
"""
).render(user="someone", users=[1, 2, 3])
)

View File

@ -1,361 +0,0 @@
"""\
This benchmark compares some python templating engines with Jinja 2 so
that we get a picture of how fast Jinja 2 is for a semi real world
template. If a template engine is not installed the test is skipped.\
"""
import sys
import cgi
from timeit import Timer
from jinja2 import Environment as JinjaEnvironment
context = {
'page_title': 'mitsuhiko\'s benchmark',
'table': [dict(a=1,b=2,c=3,d=4,e=5,f=6,g=7,h=8,i=9,j=10) for x in range(1000)]
}
jinja_template = JinjaEnvironment(
line_statement_prefix='%',
variable_start_string="${",
variable_end_string="}"
).from_string("""\
<!doctype html>
<html>
<head>
<title>${page_title|e}</title>
</head>
<body>
<div class="header">
<h1>${page_title|e}</h1>
</div>
<ul class="navigation">
% for href, caption in [
('index.html', 'Index'),
('downloads.html', 'Downloads'),
('products.html', 'Products')
]
<li><a href="${href|e}">${caption|e}</a></li>
% endfor
</ul>
<div class="table">
<table>
% for row in table
<tr>
% for cell in row
<td>${cell}</td>
% endfor
</tr>
% endfor
</table>
</div>
</body>
</html>\
""")
def test_jinja():
jinja_template.render(context)
try:
from tornado.template import Template
except ImportError:
test_tornado = None
else:
tornado_template = Template("""\
<!doctype html>
<html>
<head>
<title>{{ page_title }}</title>
</head>
<body>
<div class="header">
<h1>{{ page_title }}</h1>
</div>
<ul class="navigation">
{% for href, caption in [ \
('index.html', 'Index'), \
('downloads.html', 'Downloads'), \
('products.html', 'Products') \
] %}
<li><a href="{{ href }}">{{ caption }}</a></li>
{% end %}
</ul>
<div class="table">
<table>
{% for row in table %}
<tr>
{% for cell in row %}
<td>{{ cell }}</td>
{% end %}
</tr>
{% end %}
</table>
</div>
</body>
</html>\
""")
def test_tornado():
tornado_template.generate(**context)
try:
from django.conf import settings
settings.configure()
from django.template import Template as DjangoTemplate, Context as DjangoContext
except ImportError:
test_django = None
else:
django_template = """\
<!doctype html>
<html>
<head>
<title>{{ page_title }}</title>
</head>
<body>
<div class="header">
<h1>{{ page_title }}</h1>
</div>
<ul class="navigation">
{% for href, caption in navigation %}
<li><a href="{{ href }}">{{ caption }}</a></li>
{% endfor %}
</ul>
<div class="table">
<table>
{% for row in table %}
<tr>
{% for cell in row %}
<td>{{ cell }}</td>
{% endfor %}
</tr>
{% endfor %}
</table>
</div>
</body>
</html>\
"""
def test_django():
c = DjangoContext(context)
c['navigation'] = [('index.html', 'Index'), ('downloads.html', 'Downloads'),
('products.html', 'Products')]
# recompile template each rendering because that's what django
# is doing in normal situations too. Django is not thread safe
# so we can't cache it in regular apps either.
DjangoTemplate(django_template).render(c)
try:
from mako.template import Template as MakoTemplate
except ImportError:
test_mako = None
else:
mako_template = MakoTemplate("""\
<!doctype html>
<html>
<head>
<title>${page_title|h}</title>
</head>
<body>
<div class="header">
<h1>${page_title|h}</h1>
</div>
<ul class="navigation">
% for href, caption in [('index.html', 'Index'), ('downloads.html', 'Downloads'), ('products.html', 'Products')]:
<li><a href="${href|h}">${caption|h}</a></li>
% endfor
</ul>
<div class="table">
<table>
% for row in table:
<tr>
% for cell in row:
<td>${cell}</td>
% endfor
</tr>
% endfor
</table>
</div>
</body>
</html>\
""")
def test_mako():
mako_template.render(**context)
try:
from genshi.template import MarkupTemplate as GenshiTemplate
except ImportError:
test_genshi = None
else:
genshi_template = GenshiTemplate("""\
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/">
<head>
<title>${page_title}</title>
</head>
<body>
<div class="header">
<h1>${page_title}</h1>
</div>
<ul class="navigation">
<li py:for="href, caption in [
('index.html', 'Index'),
('downloads.html', 'Downloads'),
('products.html', 'Products')]"><a href="${href}">${caption}</a></li>
</ul>
<div class="table">
<table>
<tr py:for="row in table">
<td py:for="cell in row">${cell}</td>
</tr>
</table>
</div>
</body>
</html>\
""")
def test_genshi():
genshi_template.generate(**context).render('html', strip_whitespace=False)
try:
from Cheetah.Template import Template as CheetahTemplate
except ImportError:
test_cheetah = None
else:
cheetah_template = CheetahTemplate("""\
#import cgi
<!doctype html>
<html>
<head>
<title>$cgi.escape($page_title)</title>
</head>
<body>
<div class="header">
<h1>$cgi.escape($page_title)</h1>
</div>
<ul class="navigation">
#for $href, $caption in [('index.html', 'Index'), ('downloads.html', 'Downloads'), ('products.html', 'Products')]:
<li><a href="$cgi.escape($href)">$cgi.escape($caption)</a></li>
#end for
</ul>
<div class="table">
<table>
#for $row in $table:
<tr>
#for $cell in $row:
<td>$cell</td>
#end for
</tr>
#end for
</table>
</div>
</body>
</html>\
""", searchList=[dict(context)])
def test_cheetah():
unicode(cheetah_template)
try:
import tenjin
except ImportError:
test_tenjin = None
else:
tenjin_template = tenjin.Template()
tenjin_template.convert("""\
<!doctype html>
<html>
<head>
<title>${page_title}</title>
</head>
<body>
<div class="header">
<h1>${page_title}</h1>
</div>
<ul class="navigation">
<?py for href, caption in [('index.html', 'Index'), ('downloads.html', 'Downloads'), ('products.html', 'Products')]: ?>
<li><a href="${href}">${caption}</a></li>
<?py #end ?>
</ul>
<div class="table">
<table>
<?py for row in table: ?>
<tr>
<?py for cell in row: ?>
<td>#{cell}</td>
<?py #end ?>
</tr>
<?py #end ?>
</table>
</div>
</body>
</html>\
""")
def test_tenjin():
from tenjin.helpers import escape, to_str
tenjin_template.render(context, locals())
try:
from spitfire.compiler import util as SpitfireTemplate
from spitfire.compiler.analyzer import o2_options as spitfire_optimizer
except ImportError:
test_spitfire = None
else:
spitfire_template = SpitfireTemplate.load_template("""\
<!doctype html>
<html>
<head>
<title>$cgi.escape($page_title)</title>
</head>
<body>
<div class="header">
<h1>$cgi.escape($page_title)</h1>
</div>
<ul class="navigation">
#for $href, $caption in [('index.html', 'Index'), ('downloads.html', 'Downloads'), ('products.html', 'Products')]
<li><a href="$cgi.escape($href)">$cgi.escape($caption)</a></li>
#end for
</ul>
<div class="table">
<table>
#for $row in $table
<tr>
#for $cell in $row
<td>$cell</td>
#end for
</tr>
#end for
</table>
</div>
</body>
</html>\
""", 'spitfire_tmpl', spitfire_optimizer, {'enable_filters': False})
spitfire_context = dict(context, **{'cgi': cgi})
def test_spitfire():
spitfire_template(search_list=[spitfire_context]).main()
sys.stdout.write('\r' + '\n'.join((
'=' * 80,
'Template Engine BigTable Benchmark'.center(80),
'=' * 80,
__doc__,
'-' * 80
)) + '\n')
for test in 'jinja', 'mako', 'tornado', 'tenjin', 'spitfire', 'django', 'genshi', 'cheetah':
if locals()['test_' + test] is None:
sys.stdout.write(' %-20s*not installed*\n' % test)
continue
t = Timer(setup='from __main__ import test_%s as bench' % test,
stmt='bench()')
sys.stdout.write(' >> %-20s<running>' % test)
sys.stdout.flush()
sys.stdout.write('\r %-20s%.4f seconds\n' % (test, t.timeit(number=50) / 50))
sys.stdout.write('-' * 80 + '\n')
sys.stdout.write('''\
WARNING: The results of this benchmark are useless to compare the
performance of template engines and should not be taken seriously in any
way. It's testing the performance of simple loops and has no real-world
usefulnes. It only used to check if changes on the Jinja code affect
performance in a good or bad way and how it roughly compares to others.
''' + '=' * 80 + '\n')

View File

@ -1,49 +0,0 @@
try:
from cProfile import Profile
except ImportError:
from profile import Profile
from pstats import Stats
from jinja2 import Environment as JinjaEnvironment
context = {
'page_title': 'mitsuhiko\'s benchmark',
'table': [dict(a=1,b=2,c=3,d=4,e=5,f=6,g=7,h=8,i=9,j=10) for x in range(1000)]
}
source = """\
<!doctype html>
<html>
<head>
<title>${page_title|e}</title>
</head>
<body>
<div class="header">
<h1>${page_title|e}</h1>
</div>
<div class="table">
<table>
% for row in table
<tr>
% for cell in row
<td>${cell}</td>
% endfor
</tr>
% endfor
</table>
</div>
</body>
</html>\
"""
jinja_template = JinjaEnvironment(
line_statement_prefix='%',
variable_start_string="${",
variable_end_string="}"
).from_string(source)
print jinja_template.environment.compile(source, raw=True)
p = Profile()
p.runcall(lambda: jinja_template.render(context))
stats = Stats(p)
stats.sort_stats('time', 'calls')
stats.print_stats()

View File

@ -1 +0,0 @@
<form action="{{ action }}" method="{{ method }}">{{ body }}</form>

View File

@ -1 +0,0 @@
<input type="{{ type }}" value="{{ value }}" name="{{ name }}">

View File

@ -1 +0,0 @@
<textarea name="{{ name }}" rows="{{ rows }}" cols="{{ cols }}">{{ value }}</textarea>

View File

@ -1,29 +0,0 @@
{% extends "layout.html" %}
{% block page_title %}Index Page{% endblock %}
{% block body %}
{% for article in articles %}
{% if article.published %}
<div class="article">
<h2><a href="{{ article.href }}">{{ article.title }}</a></h2>
<p class="meta">written by <a href="{{ article.user.href }}">{{ article.user.username }}</a> on {{ article.pub_date|dateformat }}</p>
<div class="text">{{ article.body|safe }}</div>
</div>
{% endif %}
{% endfor %}
{% form %}
<dl>
<dt>Name</dt>
<dd>{% input_field 'name' %}</dd>
<dt>E-Mail</dt>
<dd>{% input_field 'email' %}</dd>
<dt>URL</dt>
<dd>{% input_field 'url' %}</dd>
<dt>Comment</dt>
<dd>{% textarea 'comment' %}</dd>
<dt>Captcha</dt>
<dd>{% input_field 'captcha' %}</dd>
</dl>
{% input_field '' 'submit' 'Submit' %}
{% input_field 'cancel' 'submit' 'Cancel' %}
{% endform %}
{% endblock %}

View File

@ -1,29 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>{% block page_title %}{% endblock %} | RealWorld Benchmark</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div class="contents">
<div class="header">
<h1>RealWorld Benchmark</h1>
<blockquote><p>
A less stupid benchmark for Mako and Jinja2 to get an impression how
code changes affect runtime performance.
</p></blockquote>
</div>
<ul class="navigation">
{% for href, caption in page_navigation %}
<li><a href="{{ href }}">{{ caption }}</a></li>
{% endfor %}
</ul>
<div class="body">
{% block body %}{% endblock %}
</div>
<div class="footer">
&copy; Copyright 2008 by I don't know who.
</div>
</div>
</body>
</html>

View File

@ -1,128 +0,0 @@
# -*- coding: utf-8 -*-
from rwbench import ROOT
from os.path import join
from django.conf import settings
settings.configure(TEMPLATE_DIRS=(join(ROOT, 'django'),))
from django.template import loader as django_loader, Context as DjangoContext, \
Node, NodeList, Variable, TokenParser
from django import template as django_template_module
from django.template import Library
# for django extensions. We monkey patch our extensions in so that
# we don't have to initialize a more complex django setup.
django_extensions = django_template_module.Library()
django_template_module.builtins.append(django_extensions)
from rwbench import dateformat
django_extensions.filter(dateformat)
def var_or_none(x):
if x is not None:
return Variable(x)
# and more django extensions
@django_extensions.tag
def input_field(parser, token):
p = TokenParser(token.contents)
args = [p.value()]
while p.more():
args.append(p.value())
return InputFieldNode(*args)
@django_extensions.tag
def textarea(parser, token):
p = TokenParser(token.contents)
args = [p.value()]
while p.more():
args.append(p.value())
return TextareaNode(*args)
@django_extensions.tag
def form(parser, token):
p = TokenParser(token.contents)
args = []
while p.more():
args.append(p.value())
body = parser.parse(('endform',))
parser.delete_first_token()
return FormNode(body, *args)
class InputFieldNode(Node):
def __init__(self, name, type=None, value=None):
self.name = var_or_none(name)
self.type = var_or_none(type)
self.value = var_or_none(value)
def render(self, context):
name = self.name.resolve(context)
type = 'text'
value = ''
if self.type is not None:
type = self.type.resolve(context)
if self.value is not None:
value = self.value.resolve(context)
tmpl = django_loader.get_template('_input_field.html')
return tmpl.render(DjangoContext({
'name': name,
'type': type,
'value': value
}))
class TextareaNode(Node):
def __init__(self, name, rows=None, cols=None, value=None):
self.name = var_or_none(name)
self.rows = var_or_none(rows)
self.cols = var_or_none(cols)
self.value = var_or_none(value)
def render(self, context):
name = self.name.resolve(context)
rows = 10
cols = 40
value = ''
if self.rows is not None:
rows = int(self.rows.resolve(context))
if self.cols is not None:
cols = int(self.cols.resolve(context))
if self.value is not None:
value = self.value.resolve(context)
tmpl = django_loader.get_template('_textarea.html')
return tmpl.render(DjangoContext({
'name': name,
'rows': rows,
'cols': cols,
'value': value
}))
class FormNode(Node):
def __init__(self, body, action=None, method=None):
self.body = body
self.action = action
self.method = method
def render(self, context):
body = self.body.render(context)
action = ''
method = 'post'
if self.action is not None:
action = self.action.resolve(context)
if self.method is not None:
method = self.method.resolve(context)
tmpl = django_loader.get_template('_form.html')
return tmpl.render(DjangoContext({
'body': body,
'action': action,
'method': method
}))

View File

@ -1,12 +0,0 @@
<div xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/"
py:strip="">
<py:def function="input_field(name='', value='', type='text')">
<input type="$type" value="$value" name="$name" />
</py:def>
<py:def function="textarea(name, value='', rows=10, cols=40)">
<textarea name="$name" rows="$rows" cols="cols">$value</textarea>
</py:def>
</div>

View File

@ -1,41 +0,0 @@
<?python
from rwbench import dateformat
?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:py="http://genshi.edgewall.org/">
<xi:include href="layout.html" />
<xi:include href="helpers.html" />
<head><title>Index Page</title></head>
<body>
<div class="article" py:for="article in articles">
<py:if test="article.published">
<h2><a href="${article.href}">${article.title}</a></h2>
<p class="meta">written by <a href="${article.user.href}"
>${article.user.username}</a> on ${dateformat(article.pub_date)}</p>
<div class="text">${Markup(article.body)}</div>
</py:if>
</div>
<!--
For a fair and balanced comparison we would have to use a def here
that wraps the form data but I don't know what would be the best
Genshi equivalent for that. Quite frankly I doubt that this makes
sense in Genshi anyways.
-->
<form action="" method="post">
<dl>
<dt>Name</dt>
<dd>${input_field('name')}</dd>
<dt>E-Mail</dt>
<dd>${input_field('email')}</dd>
<dt>URL</dt>
<dd>${input_field('url')}</dd>
<dt>Comment</dt>
<dd>${textarea('comment')}</dd>
<dt>Captcha</dt>
<dd>${input_field('captcha')}</dd>
</dl>
${input_field(type='submit', value='Submit')}
${input_field(name='cancel', type='submit', value='Cancel')}
</form>
</body>
</html>

View File

@ -1,30 +0,0 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/" >
<py:match path="head" once="true">
<head>
<title>${select('title/text()')} | RealWorld Benchmark</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
</py:match>
<py:match path="body" once="true">
<body>
<div class="contents">
<div class="header">
<h1>RealWorld Benchmark</h1>
<blockquote><p>
A less stupid benchmark for Mako and Jinja2 to get an impression how
code changes affect runtime performance.
</p></blockquote>
</div>
<ul class="navigation">
<li py:for="href, caption in page_navigation"><a href="$href">$caption</a></li>
</ul>
<div class="body">
${select('*|text()')}
</div>
<div class="footer">
&copy; Copyright 2008 by I don't know who.
</div>
</div>
</body>
</py:match>
</html>

View File

@ -1,12 +0,0 @@
{% macro input_field(name, value='', type='text') -%}
<input type="{{ type }}" value="{{ value|e }}" name="{{ name }}">
{%- endmacro %}
{% macro textarea(name, value='', rows=10, cols=40) -%}
<textarea name="{{ name }}" rows="{{ rows }}" cols="{{ cols }}">{{
value|e }}</textarea>
{%- endmacro %}
{% macro form(action='', method='post') -%}
<form action="{{ action|e }}" method="{{ method }}">{{ caller() }}</form>
{%- endmacro %}

View File

@ -1,29 +0,0 @@
{% extends "layout.html" %}
{% from "helpers.html" import input_field, textarea, form %}
{% block page_title %}Index Page{% endblock %}
{% block body %}
{%- for article in articles if article.published %}
<div class="article">
<h2><a href="{{ article.href|e }}">{{ article.title|e }}</a></h2>
<p class="meta">written by <a href="{{ article.user.href|e
}}">{{ article.user.username|e }}</a> on {{ article.pub_date|dateformat }}</p>
<div class="text">{{ article.body }}</div>
</div>
{%- endfor %}
{%- call form() %}
<dl>
<dt>Name</dt>
<dd>{{ input_field('name') }}</dd>
<dt>E-Mail</dt>
<dd>{{ input_field('email') }}</dd>
<dt>URL</dt>
<dd>{{ input_field('url') }}</dd>
<dt>Comment</dt>
<dd>{{ textarea('comment') }}</dd>
<dt>Captcha</dt>
<dd>{{ input_field('captcha') }}</dd>
</dl>
{{ input_field(type='submit', value='Submit') }}
{{ input_field('cancel', type='submit', value='Cancel') }}
{%- endcall %}
{% endblock %}

View File

@ -1,29 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>{% block page_title %}{% endblock %} | RealWorld Benchmark</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div class="contents">
<div class="header">
<h1>RealWorld Benchmark</h1>
<blockquote><p>
A less stupid benchmark for Mako and Jinja2 to get an impression how
code changes affect runtime performance.
</p></blockquote>
</div>
<ul class="navigation">
{%- for href, caption in page_navigation %}
<li><a href="{{ href|e }}">{{ caption }}</a></li>
{%- endfor %}
</ul>
<div class="body">
{% block body %}{% endblock %}
</div>
<div class="footer">
&copy; Copyright 2008 by I don't know who.
</div>
</div>
</body>
</html>

View File

@ -1,11 +0,0 @@
<%def name="input_field(name='', value='', type='text')">
<input type="${type}" value="${value|h}" name="${name}">
</%def>
<%def name="textarea(name, value='', rows=10, cols=40)">
<textarea name="${name}" rows="${rows}" cols="${cols}">${value|h}</textarea>
</%def>
<%def name="form(action='', method='post')">
<form action="${action|h}" method="${method}">${caller.body()}</form>
</%def>

View File

@ -1,31 +0,0 @@
<%!
from rwbench import dateformat
%>
<%inherit file="layout.html" />
<%namespace file="helpers.html" import="input_field, textarea, form" />
<%def name="page_title()">Index Page</%def>
% for article in articles:
<% if not article.published: continue %>
<div class="article">
<h2><a href="${article.href|h}">${article.title|h}</a></h2>
<p class="meta">written by <a href="${article.user.href|h
}">${article.user.username|h}</a> on ${dateformat(article.pub_date)}</p>
<div class="text">${article.body}</div>
</div>
% endfor
<%call expr="form()">
<dl>
<dt>Name</dt>
<dd>${input_field('name')}</dd>
<dt>E-Mail</dt>
<dd>${input_field('email')}</dd>
<dt>URL</dt>
<dd>${input_field('url')}</dd>
<dt>Comment</dt>
<dd>${textarea('comment')}</dd>
<dt>Captcha</dt>
<dd>${input_field('captcha')}</dd>
</dl>
${input_field(type='submit', value='Submit')}
${input_field(name='cancel', type='submit', value='Cancel')}
</%call>

View File

@ -1,30 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>${self.page_title()} | RealWorld Benchmark</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div class="contents">
<div class="header">
<h1>RealWorld Benchmark</h1>
<blockquote><p>
A less stupid benchmark for Mako and Jinja2 to get an impression how
code changes affect runtime performance.
</p></blockquote>
</div>
<ul class="navigation">
% for href, caption in page_navigation:
<li><a href="${href|h}">${caption}</a></li>
% endfor
</ul>
<div class="body">
${self.body()}
</div>
<div class="footer">
&copy; Copyright 2008 by I don't know who.
</div>
</div>
</body>
</html>
<%def name="page_title()"></%def>

View File

@ -1,99 +0,0 @@
# -*- coding: utf-8 -*-
"""
RealWorldish Benchmark
~~~~~~~~~~~~~~~~~~~~~~
A more real-world benchmark of Jinja2. Like the other benchmark in the
Jinja2 repository this has no real-world usefulnes (despite the name).
Just go away and ignore it. NOW!
:copyright: (c) 2009 by the Jinja Team.
:license: BSD.
"""
import sys
from os.path import join, dirname, abspath
ROOT = abspath(dirname(__file__))
from random import choice, randrange
from datetime import datetime
from timeit import Timer
from jinja2 import Environment, FileSystemLoader
from jinja2.utils import generate_lorem_ipsum
from mako.lookup import TemplateLookup
from genshi.template import TemplateLoader as GenshiTemplateLoader
def dateformat(x):
return x.strftime('%Y-%m-%d')
jinja_env = Environment(loader=FileSystemLoader(join(ROOT, 'jinja')))
jinja_env.filters['dateformat'] = dateformat
mako_lookup = TemplateLookup(directories=[join(ROOT, 'mako')])
genshi_loader = GenshiTemplateLoader([join(ROOT, 'genshi')])
class Article(object):
def __init__(self, id):
self.id = id
self.href = '/article/%d' % self.id
self.title = generate_lorem_ipsum(1, False, 5, 10)
self.user = choice(users)
self.body = generate_lorem_ipsum()
self.pub_date = datetime.utcfromtimestamp(randrange(10 ** 9, 2 * 10 ** 9))
self.published = True
class User(object):
def __init__(self, username):
self.href = '/user/%s' % username
self.username = username
users = map(User, [u'John Doe', u'Jane Doe', u'Peter Somewhat'])
articles = map(Article, range(20))
navigation = [
('index', 'Index'),
('about', 'About'),
('foo?bar=1', 'Foo with Bar'),
('foo?bar=2&s=x', 'Foo with X'),
('blah', 'Blub Blah'),
('hehe', 'Haha'),
] * 5
context = dict(users=users, articles=articles, page_navigation=navigation)
jinja_template = jinja_env.get_template('index.html')
mako_template = mako_lookup.get_template('index.html')
genshi_template = genshi_loader.load('index.html')
def test_jinja():
jinja_template.render(context)
def test_mako():
mako_template.render_unicode(**context)
from djangoext import django_loader, DjangoContext
def test_django():
# not cached because django is not thread safe and does
# not cache by itself so it would be unfair to cache it here.
django_template = django_loader.get_template('index.html')
django_template.render(DjangoContext(context))
def test_genshi():
genshi_template.generate(**context).render('html', doctype='html')
if __name__ == '__main__':
sys.stdout.write('Realworldish Benchmark:\n')
for test in 'jinja', 'mako', 'django', 'genshi':
t = Timer(setup='from __main__ import test_%s as bench' % test,
stmt='bench()')
sys.stdout.write(' >> %-20s<running>' % test)
sys.stdout.flush()
sys.stdout.write('\r %-20s%.4f seconds\n' % (test, t.timeit(number=200) / 200))

Binary file not shown.

View File

@ -1,27 +0,0 @@
" Vim syntax file
" Language: Jinja HTML template
" Maintainer: Armin Ronacher <armin.ronacher@active-4.com>
" Last Change: 2007 Apr 8
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
if !exists("main_syntax")
let main_syntax = 'html'
endif
if version < 600
so <sfile>:p:h/jinja.vim
so <sfile>:p:h/html.vim
else
runtime! syntax/jinja.vim
runtime! syntax/html.vim
unlet b:current_syntax
endif
let b:current_syntax = "htmljinja"

View File

@ -1,113 +0,0 @@
" Vim syntax file
" Language: Jinja template
" Maintainer: Armin Ronacher <armin.ronacher@active-4.com>
" Last Change: 2008 May 9
" Version: 1.1
"
" Known Bugs:
" because of odd limitations dicts and the modulo operator
" appear wrong in the template.
"
" Changes:
"
" 2008 May 9: Added support for Jinja2 changes (new keyword rules)
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
syntax case match
" Jinja template built-in tags and parameters (without filter, macro, is and raw, they
" have special threatment)
syn keyword jinjaStatement containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained and if else in not or recursive as import
syn keyword jinjaStatement containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained is filter skipwhite nextgroup=jinjaFilter
syn keyword jinjaStatement containedin=jinjaTagBlock contained macro skipwhite nextgroup=jinjaFunction
syn keyword jinjaStatement containedin=jinjaTagBlock contained block skipwhite nextgroup=jinjaBlockName
" Variable Names
syn match jinjaVariable containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained skipwhite /[a-zA-Z_][a-zA-Z0-9_]*/
syn keyword jinjaSpecial containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained false true none False True None loop super caller varargs kwargs
" Filters
syn match jinjaOperator "|" containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained nextgroup=jinjaFilter
syn match jinjaFilter contained skipwhite /[a-zA-Z_][a-zA-Z0-9_]*/
syn match jinjaFunction contained skipwhite /[a-zA-Z_][a-zA-Z0-9_]*/
syn match jinjaBlockName contained skipwhite /[a-zA-Z_][a-zA-Z0-9_]*/
" Jinja template constants
syn region jinjaString containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained start=/"/ skip=/\\"/ end=/"/
syn region jinjaString containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained start=/'/ skip=/\\'/ end=/'/
syn match jinjaNumber containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /[0-9]\+\(\.[0-9]\+\)\?/
" Operators
syn match jinjaOperator containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /[+\-*\/<>=!,:]/
syn match jinjaPunctuation containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /[()\[\]]/
syn match jinjaOperator containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /\./ nextgroup=jinjaAttribute
syn match jinjaAttribute contained /[a-zA-Z_][a-zA-Z0-9_]*/
" Jinja template tag and variable blocks
syn region jinjaNested matchgroup=jinjaOperator start="(" end=")" transparent display containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained
syn region jinjaNested matchgroup=jinjaOperator start="\[" end="\]" transparent display containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained
syn region jinjaNested matchgroup=jinjaOperator start="{" end="}" transparent display containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained
syn region jinjaTagBlock matchgroup=jinjaTagDelim start=/{%-\?/ end=/-\?%}/ skipwhite containedin=ALLBUT,jinjaTagBlock,jinjaVarBlock,jinjaRaw,jinjaString,jinjaNested,jinjaComment
syn region jinjaVarBlock matchgroup=jinjaVarDelim start=/{{-\?/ end=/-\?}}/ containedin=ALLBUT,jinjaTagBlock,jinjaVarBlock,jinjaRaw,jinjaString,jinjaNested,jinjaComment
" Jinja template 'raw' tag
syn region jinjaRaw matchgroup=jinjaRawDelim start="{%\s*raw\s*%}" end="{%\s*endraw\s*%}" containedin=ALLBUT,jinjaTagBlock,jinjaVarBlock,jinjaString,jinjaComment
" Jinja comments
syn region jinjaComment matchgroup=jinjaCommentDelim start="{#" end="#}" containedin=ALLBUT,jinjaTagBlock,jinjaVarBlock,jinjaString
" Block start keywords. A bit tricker. We only highlight at the start of a
" tag block and only if the name is not followed by a comma or equals sign
" which usually means that we have to deal with an assignment.
syn match jinjaStatement containedin=jinjaTagBlock contained skipwhite /\({%-\?\s*\)\@<=\<[a-zA-Z_][a-zA-Z0-9_]*\>\(\s*[,=]\)\@!/
" and context modifiers
syn match jinjaStatement containedin=jinjaTagBlock contained /\<with\(out\)\?\s\+context\>/ skipwhite
" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_jinja_syn_inits")
if version < 508
let did_jinja_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink jinjaPunctuation jinjaOperator
HiLink jinjaAttribute jinjaVariable
HiLink jinjaFunction jinjaFilter
HiLink jinjaTagDelim jinjaTagBlock
HiLink jinjaVarDelim jinjaVarBlock
HiLink jinjaCommentDelim jinjaComment
HiLink jinjaRawDelim jinja
HiLink jinjaSpecial Special
HiLink jinjaOperator Normal
HiLink jinjaRaw Normal
HiLink jinjaTagBlock PreProc
HiLink jinjaVarBlock PreProc
HiLink jinjaStatement Statement
HiLink jinjaFilter Function
HiLink jinjaBlockName Function
HiLink jinjaVariable Identifier
HiLink jinjaString Constant
HiLink jinjaNumber Constant
HiLink jinjaComment Comment
delcommand HiLink
endif
let b:current_syntax = "jinja"

View File

@ -1,768 +0,0 @@
# -*- coding: utf-8 -*-
"""
Django to Jinja
~~~~~~~~~~~~~~~
Helper module that can convert django templates into Jinja2 templates.
This file is not intended to be used as stand alone application but to
be used as library. To convert templates you basically create your own
writer, add extra conversion logic for your custom template tags,
configure your django environment and run the `convert_templates`
function.
Here a simple example::
# configure django (or use settings.configure)
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'yourapplication.settings'
from yourapplication.foo.templatetags.bar import MyNode
from django2jinja import Writer, convert_templates
def write_my_node(writer, node):
writer.start_variable()
writer.write('myfunc(')
for idx, arg in enumerate(node.args):
if idx:
writer.write(', ')
writer.node(arg)
writer.write(')')
writer.end_variable()
writer = Writer()
writer.node_handlers[MyNode] = write_my_node
convert_templates('/path/to/output/folder', writer=writer)
Here is an example hos to automatically translate your django
variables to jinja2::
import re
# List of tuple (Match pattern, Replace pattern, Exclusion pattern)
var_re = ((re.compile(r"(u|user)\.is_authenticated"), r"\1.is_authenticated()", None),
(re.compile(r"\.non_field_errors"), r".non_field_errors()", None),
(re.compile(r"\.label_tag"), r".label_tag()", None),
(re.compile(r"\.as_dl"), r".as_dl()", None),
(re.compile(r"\.as_table"), r".as_table()", None),
(re.compile(r"\.as_widget"), r".as_widget()", None),
(re.compile(r"\.as_hidden"), r".as_hidden()", None),
(re.compile(r"\.get_([0-9_\w]+)_url"), r".get_\1_url()", None),
(re.compile(r"\.url"), r".url()", re.compile(r"(form|calendar).url")),
(re.compile(r"\.get_([0-9_\w]+)_display"), r".get_\1_display()", None),
(re.compile(r"loop\.counter"), r"loop.index", None),
(re.compile(r"loop\.revcounter"), r"loop.revindex", None),
(re.compile(r"request\.GET\.([0-9_\w]+)"), r"request.GET.get('\1', '')", None),
(re.compile(r"request\.get_host"), r"request.get_host()", None),
(re.compile(r"\.all(?!_)"), r".all()", None),
(re.compile(r"\.all\.0"), r".all()[0]", None),
(re.compile(r"\.([0-9])($|\s+)"), r"[\1]\2", None),
(re.compile(r"\.items"), r".items()", None),
)
writer = Writer(var_re=var_re)
For details about the writing process have a look at the module code.
:copyright: (c) 2009 by the Jinja Team.
:license: BSD.
"""
import re
import os
import sys
from jinja2.defaults import *
from django.conf import settings
from django.template import defaulttags as core_tags, loader, TextNode, \
FilterExpression, libraries, Variable, loader_tags, TOKEN_TEXT, \
TOKEN_VAR
from django.template.debug import DebugVariableNode as VariableNode
from django.templatetags import i18n as i18n_tags
from StringIO import StringIO
_node_handlers = {}
_resolved_filters = {}
_newline_re = re.compile(r'(?:\r\n|\r|\n)')
# Django stores an itertools object on the cycle node. Not only is this
# thread unsafe but also a problem for the converter which needs the raw
# string values passed to the constructor to create a jinja loop.cycle()
# call from it.
_old_cycle_init = core_tags.CycleNode.__init__
def _fixed_cycle_init(self, cyclevars, variable_name=None):
self.raw_cycle_vars = map(Variable, cyclevars)
_old_cycle_init(self, cyclevars, variable_name)
core_tags.CycleNode.__init__ = _fixed_cycle_init
def node(cls):
def proxy(f):
_node_handlers[cls] = f
return f
return proxy
def convert_templates(output_dir, extensions=('.html', '.txt'), writer=None,
callback=None):
"""Iterates over all templates in the template dirs configured and
translates them and writes the new templates into the output directory.
"""
if writer is None:
writer = Writer()
def filter_templates(files):
for filename in files:
ifilename = filename.lower()
for extension in extensions:
if ifilename.endswith(extension):
yield filename
def translate(f, loadname):
template = loader.get_template(loadname)
original = writer.stream
writer.stream = f
writer.body(template.nodelist)
writer.stream = original
if callback is None:
def callback(template):
print template
for directory in settings.TEMPLATE_DIRS:
for dirname, _, files in os.walk(directory):
dirname = dirname[len(directory) + 1:]
for filename in filter_templates(files):
source = os.path.normpath(os.path.join(dirname, filename))
target = os.path.join(output_dir, dirname, filename)
basetarget = os.path.dirname(target)
if not os.path.exists(basetarget):
os.makedirs(basetarget)
callback(source)
f = file(target, 'w')
try:
translate(f, source)
finally:
f.close()
class Writer(object):
"""The core writer class."""
def __init__(self, stream=None, error_stream=None,
block_start_string=BLOCK_START_STRING,
block_end_string=BLOCK_END_STRING,
variable_start_string=VARIABLE_START_STRING,
variable_end_string=VARIABLE_END_STRING,
comment_start_string=COMMENT_START_STRING,
comment_end_string=COMMENT_END_STRING,
initial_autoescape=True,
use_jinja_autoescape=False,
custom_node_handlers=None,
var_re=[],
env=None):
if stream is None:
stream = sys.stdout
if error_stream is None:
error_stream = sys.stderr
self.stream = stream
self.error_stream = error_stream
self.block_start_string = block_start_string
self.block_end_string = block_end_string
self.variable_start_string = variable_start_string
self.variable_end_string = variable_end_string
self.comment_start_string = comment_start_string
self.comment_end_string = comment_end_string
self.autoescape = initial_autoescape
self.spaceless = False
self.use_jinja_autoescape = use_jinja_autoescape
self.node_handlers = dict(_node_handlers,
**(custom_node_handlers or {}))
self._loop_depth = 0
self._filters_warned = set()
self.var_re = var_re
self.env = env
def enter_loop(self):
"""Increments the loop depth so that write functions know if they
are in a loop.
"""
self._loop_depth += 1
def leave_loop(self):
"""Reverse of enter_loop."""
self._loop_depth -= 1
@property
def in_loop(self):
"""True if we are in a loop."""
return self._loop_depth > 0
def write(self, s):
"""Writes stuff to the stream."""
self.stream.write(s.encode(settings.FILE_CHARSET))
def print_expr(self, expr):
"""Open a variable tag, write to the string to the stream and close."""
self.start_variable()
self.write(expr)
self.end_variable()
def _post_open(self):
if self.spaceless:
self.write('- ')
else:
self.write(' ')
def _pre_close(self):
if self.spaceless:
self.write(' -')
else:
self.write(' ')
def start_variable(self):
"""Start a variable."""
self.write(self.variable_start_string)
self._post_open()
def end_variable(self, always_safe=False):
"""End a variable."""
if not always_safe and self.autoescape and \
not self.use_jinja_autoescape:
self.write('|e')
self._pre_close()
self.write(self.variable_end_string)
def start_block(self):
"""Starts a block."""
self.write(self.block_start_string)
self._post_open()
def end_block(self):
"""Ends a block."""
self._pre_close()
self.write(self.block_end_string)
def tag(self, name):
"""Like `print_expr` just for blocks."""
self.start_block()
self.write(name)
self.end_block()
def variable(self, name):
"""Prints a variable. This performs variable name transformation."""
self.write(self.translate_variable_name(name))
def literal(self, value):
"""Writes a value as literal."""
value = repr(value)
if value[:2] in ('u"', "u'"):
value = value[1:]
self.write(value)
def filters(self, filters, is_block=False):
"""Dumps a list of filters."""
want_pipe = not is_block
for filter, args in filters:
name = self.get_filter_name(filter)
if name is None:
self.warn('Could not find filter %s' % name)
continue
if name not in DEFAULT_FILTERS and \
name not in self._filters_warned:
self._filters_warned.add(name)
self.warn('Filter %s probably doesn\'t exist in Jinja' %
name)
if not want_pipe:
want_pipe = True
else:
self.write('|')
self.write(name)
if args:
self.write('(')
for idx, (is_var, value) in enumerate(args):
if idx:
self.write(', ')
if is_var:
self.node(value)
else:
self.literal(value)
self.write(')')
def get_location(self, origin, position):
"""Returns the location for an origin and position tuple as name
and lineno.
"""
if hasattr(origin, 'source'):
source = origin.source
name = '<unknown source>'
else:
source = origin.loader(origin.loadname, origin.dirs)[0]
name = origin.loadname
lineno = len(_newline_re.findall(source[:position[0]])) + 1
return name, lineno
def warn(self, message, node=None):
"""Prints a warning to the error stream."""
if node is not None and hasattr(node, 'source'):
filename, lineno = self.get_location(*node.source)
message = '[%s:%d] %s' % (filename, lineno, message)
print >> self.error_stream, message
def translate_variable_name(self, var):
"""Performs variable name translation."""
if self.in_loop and var == 'forloop' or var.startswith('forloop.'):
var = var[3:]
for reg, rep, unless in self.var_re:
no_unless = unless and unless.search(var) or True
if reg.search(var) and no_unless:
var = reg.sub(rep, var)
break
return var
def get_filter_name(self, filter):
"""Returns the filter name for a filter function or `None` if there
is no such filter.
"""
if filter not in _resolved_filters:
for library in libraries.values():
for key, value in library.filters.iteritems():
_resolved_filters[value] = key
return _resolved_filters.get(filter, None)
def node(self, node):
"""Invokes the node handler for a node."""
for cls, handler in self.node_handlers.iteritems():
if type(node) is cls or type(node).__name__ == cls:
handler(self, node)
break
else:
self.warn('Untranslatable node %s.%s found' % (
node.__module__,
node.__class__.__name__
), node)
def body(self, nodes):
"""Calls node() for every node in the iterable passed."""
for node in nodes:
self.node(node)
@node(TextNode)
def text_node(writer, node):
writer.write(node.s)
@node(Variable)
def variable(writer, node):
if node.translate:
writer.warn('i18n system used, make sure to install translations', node)
writer.write('_(')
if node.literal is not None:
writer.literal(node.literal)
else:
writer.variable(node.var)
if node.translate:
writer.write(')')
@node(VariableNode)
def variable_node(writer, node):
writer.start_variable()
if node.filter_expression.var.var == 'block.super' \
and not node.filter_expression.filters:
writer.write('super()')
else:
writer.node(node.filter_expression)
writer.end_variable()
@node(FilterExpression)
def filter_expression(writer, node):
writer.node(node.var)
writer.filters(node.filters)
@node(core_tags.CommentNode)
def comment_tag(writer, node):
pass
@node(core_tags.DebugNode)
def comment_tag(writer, node):
writer.warn('Debug tag detected. Make sure to add a global function '
'called debug to the namespace.', node=node)
writer.print_expr('debug()')
@node(core_tags.ForNode)
def for_loop(writer, node):
writer.start_block()
writer.write('for ')
for idx, var in enumerate(node.loopvars):
if idx:
writer.write(', ')
writer.variable(var)
writer.write(' in ')
if node.is_reversed:
writer.write('(')
writer.node(node.sequence)
if node.is_reversed:
writer.write(')|reverse')
writer.end_block()
writer.enter_loop()
writer.body(node.nodelist_loop)
writer.leave_loop()
writer.tag('endfor')
@node(core_tags.IfNode)
def if_condition(writer, node):
writer.start_block()
writer.write('if ')
join_with = 'and'
if node.link_type == core_tags.IfNode.LinkTypes.or_:
join_with = 'or'
for idx, (ifnot, expr) in enumerate(node.bool_exprs):
if idx:
writer.write(' %s ' % join_with)
if ifnot:
writer.write('not ')
writer.node(expr)
writer.end_block()
writer.body(node.nodelist_true)
if node.nodelist_false:
writer.tag('else')
writer.body(node.nodelist_false)
writer.tag('endif')
@node(core_tags.IfEqualNode)
def if_equal(writer, node):
writer.start_block()
writer.write('if ')
writer.node(node.var1)
if node.negate:
writer.write(' != ')
else:
writer.write(' == ')
writer.node(node.var2)
writer.end_block()
writer.body(node.nodelist_true)
if node.nodelist_false:
writer.tag('else')
writer.body(node.nodelist_false)
writer.tag('endif')
@node(loader_tags.BlockNode)
def block(writer, node):
writer.tag('block ' + node.name.replace('-', '_').rstrip('_'))
node = node
while node.parent is not None:
node = node.parent
writer.body(node.nodelist)
writer.tag('endblock')
@node(loader_tags.ExtendsNode)
def extends(writer, node):
writer.start_block()
writer.write('extends ')
if node.parent_name_expr:
writer.node(node.parent_name_expr)
else:
writer.literal(node.parent_name)
writer.end_block()
writer.body(node.nodelist)
@node(loader_tags.ConstantIncludeNode)
@node(loader_tags.IncludeNode)
def include(writer, node):
writer.start_block()
writer.write('include ')
if hasattr(node, 'template'):
writer.literal(node.template.name)
else:
writer.node(node.template_name)
writer.end_block()
@node(core_tags.CycleNode)
def cycle(writer, node):
if not writer.in_loop:
writer.warn('Untranslatable free cycle (cycle outside loop)', node=node)
return
if node.variable_name is not None:
writer.start_block()
writer.write('set %s = ' % node.variable_name)
else:
writer.start_variable()
writer.write('loop.cycle(')
for idx, var in enumerate(node.raw_cycle_vars):
if idx:
writer.write(', ')
writer.node(var)
writer.write(')')
if node.variable_name is not None:
writer.end_block()
else:
writer.end_variable()
@node(core_tags.FilterNode)
def filter(writer, node):
writer.start_block()
writer.write('filter ')
writer.filters(node.filter_expr.filters, True)
writer.end_block()
writer.body(node.nodelist)
writer.tag('endfilter')
@node(core_tags.AutoEscapeControlNode)
def autoescape_control(writer, node):
original = writer.autoescape
writer.autoescape = node.setting
writer.body(node.nodelist)
writer.autoescape = original
@node(core_tags.SpacelessNode)
def spaceless(writer, node):
original = writer.spaceless
writer.spaceless = True
writer.warn('entering spaceless mode with different semantics', node)
# do the initial stripping
nodelist = list(node.nodelist)
if nodelist:
if isinstance(nodelist[0], TextNode):
nodelist[0] = TextNode(nodelist[0].s.lstrip())
if isinstance(nodelist[-1], TextNode):
nodelist[-1] = TextNode(nodelist[-1].s.rstrip())
writer.body(nodelist)
writer.spaceless = original
@node(core_tags.TemplateTagNode)
def template_tag(writer, node):
tag = {
'openblock': writer.block_start_string,
'closeblock': writer.block_end_string,
'openvariable': writer.variable_start_string,
'closevariable': writer.variable_end_string,
'opencomment': writer.comment_start_string,
'closecomment': writer.comment_end_string,
'openbrace': '{',
'closebrace': '}'
}.get(node.tagtype)
if tag:
writer.start_variable()
writer.literal(tag)
writer.end_variable()
@node(core_tags.URLNode)
def url_tag(writer, node):
writer.warn('url node used. make sure to provide a proper url() '
'function', node)
if node.asvar:
writer.start_block()
writer.write('set %s = ' % node.asvar)
else:
writer.start_variable()
autoescape = writer.autoescape
writer.write('url(')
writer.literal(node.view_name)
for arg in node.args:
writer.write(', ')
writer.node(arg)
for key, arg in node.kwargs.items():
writer.write(', %s=' % key)
writer.node(arg)
writer.write(')')
if node.asvar:
writer.end_block()
else:
writer.end_variable()
@node(core_tags.WidthRatioNode)
def width_ratio(writer, node):
writer.warn('widthratio expanded into formula. You may want to provide '
'a helper function for this calculation', node)
writer.start_variable()
writer.write('(')
writer.node(node.val_expr)
writer.write(' / ')
writer.node(node.max_expr)
writer.write(' * ')
writer.write(str(int(node.max_width)))
writer.write(')|round|int')
writer.end_variable(always_safe=True)
@node(core_tags.WithNode)
def with_block(writer, node):
writer.warn('with block expanded into set statement. This could cause '
'variables following that block to be overriden.', node)
writer.start_block()
writer.write('set %s = ' % node.name)
writer.node(node.var)
writer.end_block()
writer.body(node.nodelist)
@node(core_tags.RegroupNode)
def regroup(writer, node):
if node.expression.var.literal:
writer.warn('literal in groupby filter used. Behavior in that '
'situation is undefined and translation is skipped.', node)
return
elif node.expression.filters:
writer.warn('filters in groupby filter used. Behavior in that '
'situation is undefined which is most likely a bug '
'in your code. Filters were ignored.', node)
writer.start_block()
writer.write('set %s = ' % node.var_name)
writer.node(node.target)
writer.write('|groupby(')
writer.literal(node.expression.var.var)
writer.write(')')
writer.end_block()
@node(core_tags.LoadNode)
def warn_load(writer, node):
writer.warn('load statement used which was ignored on conversion', node)
@node(i18n_tags.GetAvailableLanguagesNode)
def get_available_languages(writer, node):
writer.warn('make sure to provide a get_available_languages function', node)
writer.tag('set %s = get_available_languages()' %
writer.translate_variable_name(node.variable))
@node(i18n_tags.GetCurrentLanguageNode)
def get_current_language(writer, node):
writer.warn('make sure to provide a get_current_language function', node)
writer.tag('set %s = get_current_language()' %
writer.translate_variable_name(node.variable))
@node(i18n_tags.GetCurrentLanguageBidiNode)
def get_current_language_bidi(writer, node):
writer.warn('make sure to provide a get_current_language_bidi function', node)
writer.tag('set %s = get_current_language_bidi()' %
writer.translate_variable_name(node.variable))
@node(i18n_tags.TranslateNode)
def simple_gettext(writer, node):
writer.warn('i18n system used, make sure to install translations', node)
writer.start_variable()
writer.write('_(')
writer.node(node.value)
writer.write(')')
writer.end_variable()
@node(i18n_tags.BlockTranslateNode)
def translate_block(writer, node):
first_var = []
variables = set()
def touch_var(name):
variables.add(name)
if not first_var:
first_var.append(name)
def dump_token_list(tokens):
for token in tokens:
if token.token_type == TOKEN_TEXT:
writer.write(token.contents)
elif token.token_type == TOKEN_VAR:
writer.print_expr(token.contents)
touch_var(token.contents)
writer.warn('i18n system used, make sure to install translations', node)
writer.start_block()
writer.write('trans')
idx = -1
for idx, (key, var) in enumerate(node.extra_context.items()):
if idx:
writer.write(',')
writer.write(' %s=' % key)
touch_var(key)
writer.node(var.filter_expression)
have_plural = False
plural_var = None
if node.plural and node.countervar and node.counter:
have_plural = True
plural_var = node.countervar
if plural_var not in variables:
if idx > -1:
writer.write(',')
touch_var(plural_var)
writer.write(' %s=' % plural_var)
writer.node(node.counter)
writer.end_block()
dump_token_list(node.singular)
if node.plural and node.countervar and node.counter:
writer.start_block()
writer.write('pluralize')
if node.countervar != first_var[0]:
writer.write(' ' + node.countervar)
writer.end_block()
dump_token_list(node.plural)
writer.tag('endtrans')
@node("SimpleNode")
def simple_tag(writer, node):
"""Check if the simple tag exist as a filter in """
name = node.tag_name
if writer.env and \
name not in writer.env.filters and \
name not in writer._filters_warned:
writer._filters_warned.add(name)
writer.warn('Filter %s probably doesn\'t exist in Jinja' %
name)
if not node.vars_to_resolve:
# No argument, pass the request
writer.start_variable()
writer.write('request|')
writer.write(name)
writer.end_variable()
return
first_var = node.vars_to_resolve[0]
args = node.vars_to_resolve[1:]
writer.start_variable()
# Copied from Writer.filters()
writer.node(first_var)
writer.write('|')
writer.write(name)
if args:
writer.write('(')
for idx, var in enumerate(args):
if idx:
writer.write(', ')
if var.var:
writer.node(var)
else:
writer.literal(var.literal)
writer.write(')')
writer.end_variable()
# get rid of node now, it shouldn't be used normally
del node

View File

@ -1,7 +0,0 @@
from django.conf import settings
settings.configure(TEMPLATE_DIRS=['templates'], TEMPLATE_DEBUG=True)
from django2jinja import convert_templates, Writer
writer = Writer(use_jinja_autoescape=True)
convert_templates('converted', writer=writer)

View File

@ -1,58 +0,0 @@
{% extends "layout.html" %}
{% load i18n %}
{% block title %}Foo{% endblock %}
{% block page-body %}
{{ block.super }}
Hello {{ name|cut:"d" }}!
{% for item in seq reversed %}
{% if forloop.index|divisibleby:2 %}
<li class="{% cycle 'a' 'b' %}">{{ item }}</li>
{% endif %}
{% endfor %}
{% ifequal foo bar %}
haha
{% else %}
hmm
{% endifequal %}
{% filter upper %}
{% include "subtemplate.html" %}
{% include foo %}
{% endfilter %}
{% spaceless %}
Hello World
{{ foo }}
Hmm
{% endspaceless %}
{% templatetag opencomment %}...{% templatetag closecomment %}
{% url foo a, b, c=d %}
{% url foo a, b, c=d as hmm %}
{% with object.value as value %}
<img src='bar.gif' height='10' width='{% widthratio value 200 100 %}'>
{% endwith %}
<pre>{% debug %}</pre>
{% blocktrans with book|title as book_t and author|title as author_t %}
This is {{ book_t }} by {{ author_t }}
{% endblocktrans %}
{% blocktrans count list|length as counter %}
There is only one {{ name }} object.
{% plural %}
There are {{ counter }} {{ name }} objects.
{% endblocktrans %}
{% blocktrans with name|escape as name count list|length as counter %}
There is only one {{ name }} object.
{% plural %}
There are {{ counter }} {{ name }} objects.
{% endblocktrans %}
{% blocktrans %}This string will have {{ value }} inside.{% endblocktrans %}
<p>{% trans "This is the title." %}</p>
{% regroup people by gender as grouped %}
{% endblock %}

View File

@ -1,4 +0,0 @@
<title>{% block title %}{% endblock %}</title>
<div class="body">
{% block page-body %}{% endblock %}
</div>

Some files were not shown because too many files have changed in this diff Show More