class BlockContext
from django.template.loader_tags import BlockContext
Ancestors (MRO)
- builtins.object
- django.template.loader_tags.BlockContext
Attribute | Type | Defined in |
---|---|---|
__dict__ |
getset_descriptor
|
django.template.loader_tags.BlockContext |
__weakref__ |
getset_descriptor
|
django.template.loader_tags.BlockContext |
def __init__(self)
django.template.loader_tags.BlockContext
Initialize self. See help(type(self)) for accurate signature.
def __init__(self):
# Dictionary of FIFO queues.
self.blocks = defaultdict(list)
def __repr__(self)
django.template.loader_tags.BlockContext
Return repr(self).
def __repr__(self):
return f"<{self.__class__.__qualname__}: blocks={self.blocks!r}>"
def add_blocks(self, blocks)
django.template.loader_tags.BlockContext
def add_blocks(self, blocks):
for name, block in blocks.items():
self.blocks[name].insert(0, block)
def get_block(self, name)
django.template.loader_tags.BlockContext
def get_block(self, name):
try:
return self.blocks[name][-1]
except IndexError:
return None
def pop(self, name)
django.template.loader_tags.BlockContext
def pop(self, name):
try:
return self.blocks[name].pop()
except IndexError:
return None
def push(self, name, block)
django.template.loader_tags.BlockContext
def push(self, name, block):
self.blocks[name].append(block)