Debian Codegraph @

PKG-INFO

raw
1 Metadata-Version: 2.1
2 Name: aiohttp-jinja2
3 Version: 1.6
4 Summary: jinja2 template renderer for aiohttp.web (http server for asyncio)
5 Home-page: https://github.com/aio-libs/aiohttp_jinja2/
6 Author: Andrew Svetlov
7 Author-email: [email protected]
8 License: Apache 2
9 Classifier: License :: OSI Approved :: Apache Software License
10 Classifier: Intended Audience :: Developers
11 Classifier: Programming Language :: Python
12 Classifier: Programming Language :: Python :: 3
13 Classifier: Programming Language :: Python :: 3.8
14 Classifier: Programming Language :: Python :: 3.9
15 Classifier: Programming Language :: Python :: 3.10
16 Classifier: Programming Language :: Python :: 3.11
17 Classifier: Programming Language :: Python :: 3.12
18 Classifier: Development Status :: 5 - Production/Stable
19 Classifier: Topic :: Internet :: WWW/HTTP
20 Classifier: Framework :: AsyncIO
21 Classifier: Framework :: aiohttp
22 Requires-Python: >=3.8
23 License-File: LICENSE
24 Requires-Dist: aiohttp>=3.9.0
25 Requires-Dist: jinja2>=3.0.0
26
27 aiohttp_jinja2
28 ==============
29 .. image:: https://github.com/aio-libs/aiohttp-jinja2/workflows/CI/badge.svg
30 :target: https://github.com/aio-libs/aiohttp-jinja2/actions?query=workflow%3ACI
31 .. image:: https://codecov.io/gh/aio-libs/aiohttp-jinja2/branch/master/graph/badge.svg
32 :target: https://codecov.io/gh/aio-libs/aiohttp-jinja2
33 .. image:: https://img.shields.io/pypi/v/aiohttp-jinja2.svg
34 :target: https://pypi.python.org/pypi/aiohttp-jinja2
35 .. image:: https://readthedocs.org/projects/aiohttp-jinja2/badge/?version=latest
36 :target: http://aiohttp-jinja2.readthedocs.io/en/latest/?badge=latest
37
38
39 jinja2_ template renderer for `aiohttp.web`__.
40
41
42 .. _jinja2: http://jinja.pocoo.org
43
44 .. _aiohttp_web: https://aiohttp.readthedocs.io/en/latest/web.html
45
46 __ aiohttp_web_
47
48 Installation
49 ------------
50 Install from PyPI::
51
52 pip install aiohttp-jinja2
53
54
55 Developing
56 ----------
57
58 Install requirement and launch tests::
59
60 pip install -r requirements-dev.txt
61 pytest tests
62
63
64 Usage
65 -----
66
67 Before template rendering you have to setup *jinja2 environment* first:
68
69 .. code-block:: python
70
71 app = web.Application()
72 aiohttp_jinja2.setup(app,
73 loader=jinja2.FileSystemLoader('/path/to/templates/folder'))
74
75 Import:
76
77 .. code-block:: python
78
79 import aiohttp_jinja2
80 import jinja2
81
82 After that you may to use template engine in your *web-handlers*. The
83 most convenient way is to decorate a *web-handler*.
84
85 Using the function based web handlers:
86
87 .. code-block:: python
88
89 @aiohttp_jinja2.template('tmpl.jinja2')
90 def handler(request):
91 return {'name': 'Andrew', 'surname': 'Svetlov'}
92
93 Or for `Class Based Views
94 <https://aiohttp.readthedocs.io/en/stable/web_quickstart.html#class-based-views>`:
95
96 .. code-block:: python
97
98 class Handler(web.View):
99 @aiohttp_jinja2.template('tmpl.jinja2')
100 async def get(self):
101 return {'name': 'Andrew', 'surname': 'Svetlov'}
102
103
104 On handler call the ``aiohttp_jinja2.template`` decorator will pass
105 returned dictionary ``{'name': 'Andrew', 'surname': 'Svetlov'}`` into
106 template named ``tmpl.jinja2`` for getting resulting HTML text.
107
108 If you need more complex processing (set response headers for example)
109 you may call ``render_template`` function.
110
111 Using a function based web handler:
112
113 .. code-block:: python
114
115 async def handler(request):
116 context = {'name': 'Andrew', 'surname': 'Svetlov'}
117 response = aiohttp_jinja2.render_template('tmpl.jinja2',
118 request,
119 context)
120 response.headers['Content-Language'] = 'ru'
121 return response
122
123 Or, again, a class based view:
124
125 .. code-block:: python
126
127 class Handler(web.View):
128 async def get(self):
129 context = {'name': 'Andrew', 'surname': 'Svetlov'}
130 response = aiohttp_jinja2.render_template('tmpl.jinja2',
131 self.request,
132 context)
133 response.headers['Content-Language'] = 'ru'
134 return response
135
136
137 License
138 -------
139
140 ``aiohttp_jinja2`` is offered under the Apache 2 license.
141
142
143 =======
144 CHANGES
145 =======
146
147 .. towncrier release notes start
148
149 1.6 (2023-11-18)
150 ================
151
152 - Switch to ``aiohttp.web.AppKey``, and deprecate the old 'static_root_url' key.
153 - Drop Python 3.7, add Python 3.12.
154
155 1.5.1 (2023-02-01)
156 ==================
157
158 - Add support for Python 3.11.
159 - Drop support for decorating non-async functions with @template (deprecated since 0.16).
160
161 1.5 (2021-08-21)
162 ================
163
164 - Drop support for jinaj2 <3. Add support for 3+.
165 - Don't require ``typing_extensions`` on Python 3.8+.
166
167 1.4.2 (2020-11-23)
168 ==================
169
170 - Add CHANGES.rst to MANIFEST.in and sdist #402
171
172 1.4.1 (2020-11-22)
173 ==================
174
175 - Document async rendering functions #396
176
177 1.4.0 (2020-11-12)
178 ==================
179
180 - Fix type annotation for ``context_processors`` argument #354
181
182 - Bump the minimal supported ``aiohttp`` version to 3.6.3 to avoid problems
183 with uncompatibility between ``aiohttp`` and ``yarl``
184
185 - Add async rendering support #393
186
187 1.3.0 (2020-10-30)
188 ==================
189
190 - Remove Any from template annotations #343
191
192 - Fix type annotation for filters in ``aiohttp_jinja2.setup`` #330
193
194 - Drop Python 3.5, support Python 3.9
195
196
197 1.2.0 (2019-10-21)
198 ==================
199
200 - Add type hints #285
201
202 1.1.1 (2019-04-25)
203 ==================
204
205 - Bump minimal supported ``jinja2`` version to 2.10.1 to avoid security vulnerability problem.
206
207
208 1.1.0 (2018-09-05)
209 ==================
210
211 - Bump minimal supported ``aiohttp`` version to 3.2
212
213 - Use ``request.config_dict`` for accessing ``jinja2`` environment. It
214 allows to reuse jinja rendering engine from parent application.
215
216 1.0.0 (2018-03-12)
217 ==================
218
219 - Allow context_processors to compose from parent apps #195
220
221 0.17.0 (2018-03-12)
222 ===================
223
224 - Auto-cast ``int`` values in ``url()`` jinja function to ``str`` #191
225
226 0.16.0 (2018-02-12)
227 ===================
228
229 - Pin to aiohttp 3.0+
230
231 - Deprecate non-async handlers support
232
233 0.15.0 (2018-01-30)
234 ===================
235
236 - Upgrade middleware to new style from aiohttp 2.3+ #182
237
238 - Autoescape all templates by default #179
239
240
241 0.13.0 (2016-12-14)
242 ===================
243
244 - Avoid subtle errors by copying context processor data #51
245
246 0.12.0 (2016-12-02)
247 ===================
248
249 - Add autodeploy script #46
250
251 0.11.0 (2016-11-24)
252 ===================
253
254 - Add jinja2 filters support #41
255
256 0.10.0 (2016-10-20)
257 ===================
258
259 - Rename package to aiohttp-jinja2 #31
260
261 0.9.0 (2016-09-26)
262 ==================
263
264 - Fix reason parameter in HTTPInternalServerError when template is not
265 found #33
266
267 0.8.0 (2016-07-12)
268 ==================
269
270 - Add ability to render template without context #28
271
272 0.7.0 (2015-12-30)
273 ==================
274
275 - Add ability to decorate class based views (available in aiohttp 0.20) #18
276
277 - Upgrade aiohttp requirement to version 0.20.0+
278
279 0.6.2 (2015-11-22)
280 ==================
281
282 - Make app_key parameter from render_string coroutine optional
283
284 0.6.0 (2015-10-29)
285 ==================
286
287 - Fix a bug in middleware (missed coroutine decorator) #16
288
289 - Drop Python 3.3 support (switched to aiohttp version v0.18.0)
290
291 - Simplify context processors initialization by adding parameter to `setup()`
292
293 0.5.0 (2015-07-09)
294 ==================
295
296 - Introduce context processors #14
297
298 - Bypass StreamResponse #15
299
300 0.4.3 (2015-06-01)
301 ==================
302
303 - Fix distribution building: add manifest file
304
305 0.4.2 (2015-05-21)
306 ==================
307
308 - Make HTTPInternalServerError exceptions more verbose on console
309 output
310
311 0.4.1 (2015-04-05)
312 ==================
313
314 - Documentation update
315
316 0.4.0 (2015-04-02)
317 ==================
318
319 - Add `render_string` method
320
321 0.3.1 (2015-04-01)
322 ==================
323
324 - Don't allow non-mapping context
325
326 - Fix tiny documentation issues
327
328 - Change the library logo
329
330 0.3.0 (2015-03-15)
331 ==================
332
333 - Documentation release
334
335 0.2.1 (2015-02-15)
336 ==================
337
338 - Fix `render_template` function
339
340 0.2.0 (2015-02-05)
341 ==================
342
343 - Migrate to aiohttp 0.14
344
345 - Add `status` parameter to template decorator
346
347 - Drop optional `response` parameter
348
349 0.1.0 (2015-01-08)
350 ==================
351
352 - Initial release