MCPcopy
hub / github.com/django/django / render_annotated

Method render_annotated

django/template/base.py:1060–1084  ·  view source on GitHub ↗

Render the node. If debug is True and an exception occurs during rendering, the exception is annotated with contextual line information where it occurred in the template. For internal usage this method is preferred over using the render method directly.

(self, context)

Source from the content-addressed store, hash-verified

1058 pass
1059
1060 def render_annotated(self, context):
1061 """
1062 Render the node. If debug is True and an exception occurs during
1063 rendering, the exception is annotated with contextual line information
1064 where it occurred in the template. For internal usage this method is
1065 preferred over using the render method directly.
1066 """
1067 try:
1068 return self.render(context)
1069 except Exception as e:
1070 if context.template.engine.debug:
1071 # Store the actual node that caused the exception.
1072 if not hasattr(e, "_culprit_node"):
1073 e._culprit_node = self
1074 if (
1075 not hasattr(e, "template_debug")
1076 and context.render_context.template.origin == e._culprit_node.origin
1077 ):
1078 e.template_debug = (
1079 context.render_context.template.get_exception_info(
1080 e,
1081 e._culprit_node.token,
1082 )
1083 )
1084 raise
1085
1086 def get_nodes_by_type(self, nodetype):
1087 """

Callers 2

renderMethod · 0.45
renderMethod · 0.45

Calls 2

renderMethod · 0.95
get_exception_infoMethod · 0.45

Tested by

no test coverage detected