MCPcopy
hub / github.com/pallets/jinja / render

Method render

src/jinja2/environment.py:1275–1295  ·  src/jinja2/environment.py::Template.render

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)

Source from the content-addressed store, hash-verified

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

Calls 4

render_asyncMethod · 0.95
new_contextMethod · 0.95
runMethod · 0.80
handle_exceptionMethod · 0.80

Tested by 15

test_loop_idxFunction · 0.76
test_loop_idx0Function · 0.76
test_call_with_argsMethod · 0.76
test_else_loop_bugMethod · 0.76
test_layoutMethod · 0.36
test_level1Method · 0.36