MCPcopy Index your code
hub / github.com/nodejs/node / generate

Method generate

tools/inspector_protocol/jinja2/environment.py:1029–1045  ·  view source on GitHub ↗

For very large templates it can be useful to not render the whole template at once but evaluate each statement after another and yield piece for piece. This method basically does exactly that and returns a generator that yields one item after another as unicode strings.

(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

1027 return TemplateStream(self.generate(*args, **kwargs))
1028
1029 def generate(self, *args, **kwargs):
1030 """For very large templates it can be useful to not render the whole
1031 template at once but evaluate each statement after another and yield
1032 piece for piece. This method basically does exactly that and returns
1033 a generator that yields one item after another as unicode strings.
1034
1035 It accepts the same arguments as :meth:`render`.
1036 """
1037 vars = dict(*args, **kwargs)
1038 try:
1039 for event in self.root_render_func(self.new_context(vars)):
1040 yield event
1041 except Exception:
1042 exc_info = sys.exc_info()
1043 else:
1044 return
1045 yield self.environment.handle_exception(exc_info, True)
1046
1047 def generate_async(self, *args, **kwargs):
1048 """An async version of :meth:`generate`. Works very similarly but

Callers 2

streamMethod · 0.95
runTestsFunction · 0.45

Calls 3

new_contextMethod · 0.95
exc_infoMethod · 0.80
handle_exceptionMethod · 0.45

Tested by

no test coverage detected