MCPcopy Create free account
hub / github.com/nodejs/node / TemplateExpression

Class TemplateExpression

deps/v8/third_party/jinja2/environment.py:1561–1577  ·  view source on GitHub ↗

The :meth:`jinja2.Environment.compile_expression` method returns an instance of this object. It encapsulates the expression-like access to the template with an expression it wraps.

Source from the content-addressed store, hash-verified

1559
1560
1561class TemplateExpression:
1562 """The :meth:`jinja2.Environment.compile_expression` method returns an
1563 instance of this object. It encapsulates the expression-like access
1564 to the template with an expression it wraps.
1565 """
1566
1567 def __init__(self, template: Template, undefined_to_none: bool) -> None:
1568 self._template = template
1569 self._undefined_to_none = undefined_to_none
1570
1571 def __call__(self, *args: t.Any, **kwargs: t.Any) -> t.Optional[t.Any]:
1572 context = self._template.new_context(dict(*args, **kwargs))
1573 consume(self._template.root_render_func(context)) # type: ignore
1574 rv = context.vars["result"]
1575 if self._undefined_to_none and isinstance(rv, Undefined):
1576 rv = None
1577 return rv
1578
1579
1580class TemplateStream:

Callers 1

compile_expressionMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected