Search code examples
viewweb2pyextend

The part of the view after an `extend` statement is not rendered


I'm trying to use the extend keyword to add a comment-box (a view placed under default/comment_box.html) across several of my views, by:

...
<hr/>
{{extend "default/comment_box.html"}}
<span id="master">
...

But, when this executes, all the part of the view after the extend statement is not being rendered and all I'm getting is:

...
<hr/>
<!--Content from the Comment-Box-->

As you can see, the part after the extend statement, i.e. <span id="master"> has gone missing. The Web2Py examples seem to be doing it the same way. Am I missing something here? Why is it truncating abruptly after the extend statement?


Solution

  • I think you want:

    {{include 'default/comment_box.html'}}
    

    If you use {{extend 'default/comment_box.html'}}, the comment_box.html view must contain an {{include}} directive somewhere, in which case, the content of the extending view gets included in place of that {{include}} directive. On the other hand, if you simply want to include the contents of comment_box.html within your view, you need to use {{include 'default/comment_box.html'}}.

    See here for more on extend and include.