djangosnippets.org: Latest snippets tagged with 'blocks'https://djangosnippets.org/tags/blocks/2008-08-04T18:17:47.429198-05:00Render specific blocks from templates (useful for AJAX, alternative)
2008-08-04T18:17:47.429198-05:00zbyte64https://djangosnippets.org/snippets/942/<p>Special thanks to the author of snippet 769 who provided most of the code for this snippet. </p>
<p>Major differences:</p>
<p>1.Simpler/better handling of "extends" block tag
2.Searches If/Else blocks
3.Less code
4.Allow list of templates to be passed which is closer to the behavior of render_to_response</p>
Freely redistributableRender specific blocks from templates (useful for AJAX)
2008-05-22T14:48:23.080400-05:00sciyoshihttps://djangosnippets.org/snippets/769/<p>Allows getting the rendered content of a specific block tag. Useful if you want to send just a part of a template back for an AJAX request. Works for arbitrary template inheritance, even if a block is defined in the child template but not in the parent.</p>
<p>Example:</p>
<p>In <code>test1.html …</code></p>
Freely redistributable