This method accepts the same arguments as the `dict` constructor: A dict, a dict subclass or some keyword arguments. If no arguments are given the context will be empty. These two calls do the same:: template.render(knights='that say nih') template.render({
(self, *args: t.Any, **kwargs: t.Any)
| 1273 | return t |
| 1274 | |
| 1275 | def render(self, *args: t.Any, **kwargs: t.Any) -> str: |
| 1276 | class="st">"""This method accepts the same arguments as the `dict` constructor: |
| 1277 | A dict, a dict subclass or some keyword arguments. If no arguments |
| 1278 | are given the context will be empty. These two calls do the same:: |
| 1279 | |
| 1280 | template.render(knights=&class="cm">#x27;that say nih') |
| 1281 | template.render({&class="cm">#x27;knightsclass="st">': 'that say nih'}) |
| 1282 | |
| 1283 | This will return the rendered template as a string. |
| 1284 | class="st">""" |
| 1285 | if self.environment.is_async: |
| 1286 | import asyncio |
| 1287 | |
| 1288 | return asyncio.run(self.render_async(*args, **kwargs)) |
| 1289 | |
| 1290 | ctx = self.new_context(dict(*args, **kwargs)) |
| 1291 | |
| 1292 | try: |
| 1293 | return self.environment.concat(self.root_render_func(ctx)) class="cm"># type: ignore |
| 1294 | except Exception: |
| 1295 | self.environment.handle_exception() |
| 1296 | |
| 1297 | async def render_async(self, *args: t.Any, **kwargs: t.Any) -> str: |
| 1298 | class="st">"""This works similar to :meth:`render` but returns a coroutine |