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

Method render

src/jinja2/nativetypes.py:98–112  ·  src/jinja2/nativetypes.py::NativeTemplate.render

Render the template to produce a native Python type. If the result is a single node, its value is returned. Otherwise, the nodes are concatenated as strings. If the result can be parsed with :func:`ast.literal_eval`, the parsed value is returned. Otherwise, the string

(self, *args: t.Any, **kwargs: t.Any)

Source from the content-addressed store, hash-verified

96 environment_class = NativeEnvironment
97
98 def render(self, *args: t.Any, **kwargs: t.Any) -> t.Any:
99 class="st">"""Render the template to produce a native Python type. If the
100 result is a single node, its value is returned. Otherwise, the
101 nodes are concatenated as strings. If the result can be parsed
102 with :func:`ast.literal_eval`, the parsed value is returned.
103 Otherwise, the string is returned.
104 class="st">"""
105 ctx = self.new_context(dict(*args, **kwargs))
106
107 try:
108 return self.environment_class.concat( class="cm"># type: ignore
109 self.root_render_func(ctx)
110 )
111 except Exception:
112 return self.environment.handle_exception()
113
114 async def render_async(self, *args: t.Any, **kwargs: t.Any) -> t.Any:
115 if not self.environment.is_async:

Callers

nothing calls this directly

Calls 2

new_contextMethod · 0.80
handle_exceptionMethod · 0.80

Tested by

no test coverage detected