Created
June 22, 2016 10:00
-
-
Save dwickstrom/1b8613b6e02d165c0a326731e53785dd to your computer and use it in GitHub Desktop.
Workaround for the inability to access the full context inside a block inside a StreamField in Wagtail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% for block in self.body %} | |
<section class="{{ block.block_type }}"> | |
{% if block.block_type == 'fooblock' %} | |
{% get_foo block.value request %} | |
{% else %} | |
{{ block}} | |
{% endif %} | |
</section> | |
{% endfor %} | |
@register.inclusion_tag('home/tags/foo.html', takes_context=True) | |
def get_foo(context, block, request): | |
return { | |
'block': block, | |
'request': context['request'], | |
} | |
# foo.html | |
<section> | |
{{ request }} | |
</section> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment