コード例 #1
0
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
ファイル: repeat.py プロジェクト: artscoop/scoop
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
コード例 #5
0
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
ファイル: hq_shared_tags.py プロジェクト: dimagi/commcare-hq
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
ファイル: repeatedblocks.py プロジェクト: VickyMutai/gallery
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
ファイル: sameastags.py プロジェクト: natevw/django-sameas
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)