0

According to Django official doc, it reads,

The template system works in a two-step process: compiling (parsing template texts to Nodes) and rendering (render Nodes to HTML file).

Let us take django-contrib-comments as an example, if I have below line in HTML template file,

{% render_comment_form for page %}

when and how will the BaseCommentNode.render()(source code here) or any other Nodes' render() be triggered? From the source code, I did not see anywhere explicitly trigger the render() function.

Yan Tian
  • 377
  • 3
  • 11

1 Answers1

0

I believe I found that answer from Django Official Document.

When Django compiles a template, it splits the raw template text into ‘’nodes’’. Each node is an instance of django.template.Node and has a render() method. A compiled template is a list of Node objects. When you call render() on a compiled template object, the template calls render() on each Node in its node list, with the given context. The results are all concatenated together to form the output of the template.

Yan Tian
  • 377
  • 3
  • 11