Hi all.
How do I reliably render just a single block in a template? This
would be really useful to serve Pjax requests -- i.e. to replace part
of the DOM instead of the whole page. The following code works fine
when the block is defined directly in the rendered template:
def render_block(template, block_name, context):
for name, render in template.blocks.iteritems():
if name == block_name:
return render(context)
render_block('content')
...but not if the content block is defined higher up in the
inheritance chain. Can I use template.module to get the inherited
template block? Can I use the compiler to pull out the block node
somehow? When using the compiler like env.parse(template) all I see
is TemplateData(data=u"<Template 'inherited.html'>") at the top level;
I don't know exactly what to do with this node. Ideally, I'd like to
also retain jinja's caching for speed. Any hints? Do I have to make
a custom AST visitor?
This same question was posed before but I still can't figure it out:
http://groups.google.com/group/pocoo-libs/browse_thread/thread/939d45969a1dde76/ee12b0fe4e4e85e3?lnk=gst&q=blocks#ee12b0fe4e4e85e3
thanks, Kumar
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pocoo-libs?hl=en.