def unwind_do_block(parser, token):
    """Replace the {% block %} tag with a debug-enhanced version"""
    original_node = do_block(parser, token)
    return UnwindBlockNode(original_node.name,
                           original_node.nodelist,
                           parent=original_node.parent,
                           tmplsrc=token.source[0].loadname)
Пример #2
0
def do_macro(parser, token):
    # let the block parse itself
    result = do_block(parser, token)
    # "upgrade" the BlockNode to a MacroNode and return it. Yes, I was not 
    # completely comfortable with it either at first, but Google says it's ok.
    result.__class__ = MacroNode
    return result
Пример #3
0
def do_macro(parser, token):
    # let the block parse itself
    result = do_block(parser, token)
    # "upgrade" the BlockNode to a MacroNode and return it. Yes, I was not
    # completely comfortable with it either at first, but Google says it's ok.
    result.__class__ = MacroNode
    return result
Пример #4
0
def do_macro(parser, token):
    """ Renvoyer un nœud macro """
    # Créer le nœud de bloc
    result = do_block(parser, token)
    # Et le transformer en bloc macro (ça marche, héritage direct)
    result.__class__ = MacroNode
    return result
def unwind_do_block(parser, token):
    """Replace the {% block %} tag with a debug-enhanced version"""
    original_node = do_block(parser, token)
    return UnwindBlockNode(original_node.name,
                           original_node.nodelist,
                           parent=original_node.parent,
                           tmplsrc=token.source[0].loadname)
Пример #6
0
def appending_block(parser, token):
    """
    this overrides {% block %} to include the combined contents of
    all {% addtoblock %} nodes
    """
    node = loader_tags.do_block(parser, token)
    node.__class__ = AppendingBlockNode
    return node
Пример #7
0
def appending_block(parser, token):
    """
    this overrides {% block %} to include the combined contents of
    all {% addtoblock %} nodes
    """
    node = loader_tags.do_block(parser, token)
    node.__class__ = AppendingBlockNode
    return node
Пример #8
0
def repeated_block(parser, token):
    try:
        tag_name, block_name = token.split_contents()
    except ValueError:
        raise template.TemplateSyntaxError(
            '{0} tag takes only one argument'.format(
                token.contents.split()[0]))
    # initialize attribute storing block contents on parser
    set_repeated_blocks(parser)
    # do_block is the internal function for creating block tags
    block_node = do_block(parser, token)
    # store block in parser's attribute
    parser._repeated_blocks[block_name] = block_node
    # return a normal block node so that it behaves exactly
    # as people would expect.
    return block_node
Пример #9
0
def repeated_block(parser, token):
    try:
        tag_name, block_name = token.split_contents()
    except ValueError:
        raise template.TemplateSyntaxError(
            '{0} tag takes only one argument'.format(
                token.contents.split()[0]))
    # initialize attribute storing block contents on parser
    set_repeated_blocks(parser)
    # do_block is the internal function for creating block tags
    block_node = do_block(parser, token)
    # store block in parser's attribute
    parser._repeated_blocks[block_name] = block_node
    # return a normal block node so that it behaves exactly
    # as people would expect.
    return block_node
Пример #10
0
def modified_do_block(parser, token):
    node = do_block(parser, token)
    return BlockNodeProxy(node.name, node.nodelist)
Пример #11
0
def modified_do_block(parser, token):
    node = do_block(parser, token)
    return BlockNodeProxy(node.name, node.nodelist)