# Path: parm/_compat.py
# PY3 = sys.version_info[0] == 3
# PY2 = sys.version_info[0] == 2
# PY26 = sys.version_info[0:2] == (2, 6)
# PYPY = hasattr(sys, 'pypy_translation_info')
#     def reraise(tp, value, tb=None):
#     def u(s, encoding='utf8'):
#     def b(s):
#     def implements_iterator(cls):
#     def python_2_unicode_compatible(cls):
#     def u(s, encoding='utf8'):
#     def b(s, encoding='utf8'):
#     def exec_(code, globs=None, locs=None):
#     def next(it):
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
# def import_(module, objects=None, via=None):
#     class metaclass(meta):


from ._compat import exec_, u, string_types, open
import re
import os
import io
import cgi
    def __str__(self):
        return self.render()
    
    def render(self):
        s = []
        for x in self.nodes:
            s.append(u(str(x)))
        return ''.join(s)
    
class BlockNode(BaseBlockNode):
    def add(self, node):
        self.nodes.append(node)
        if isinstance(node, BlockNode):
            v = self.content.root.block_vars.setdefault(node.name, [])
            v.append(node)
        
    def merge(self, content):
        self.nodes.extend(content.nodes)
    
    def render(self, top=True):
        """
        Top: if output the toppest block node
        """
        if top and self.name in self.content.root.block_vars and self is not self.content.root.block_vars[self.name][-1]:
            return self.content.root.block_vars[self.name][-1].render(False)
        
        s = []
        for x in self.nodes:
            if isinstance(x, BlockNode):
                if x.name in self.content.root.block_vars:

# Path: parm/_compat.py
# PY3 = sys.version_info[0] == 3
# PY2 = sys.version_info[0] == 2
# PY26 = sys.version_info[0:2] == (2, 6)
# PYPY = hasattr(sys, 'pypy_translation_info')
#     def reraise(tp, value, tb=None):
#     def u(s, encoding='utf8'):
#     def b(s):
#     def implements_iterator(cls):
#     def python_2_unicode_compatible(cls):
#     def u(s, encoding='utf8'):
#     def b(s, encoding='utf8'):
#     def exec_(code, globs=None, locs=None):
#     def next(it):
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
# def import_(module, objects=None, via=None):
#     class metaclass(meta):


# Path: parm/template.py
from ._compat import exec_, u, string_types, open
import re
import os
import io
import cgi

    def __str__(self):
        return self.render()
    
    def render(self):
        s = []
        for x in self.nodes:
            s.append(u(str(x)))
        return ''.join(s)
    
class BlockNode(BaseBlockNode):
    def add(self, node):
        self.nodes.append(node)
        if isinstance(node, BlockNode):
            v = self.content.root.block_vars.setdefault(node.name, [])
            v.append(node)
        
    def merge(self, content):
        self.nodes.extend(content.nodes)
    
    def render(self, top=True):
        """
        Top: if output the toppest block node
        """
        if top and self.name in self.content.root.block_vars and self is not self.content.root.block_vars[self.name][-1]:
            return self.content.root.block_vars[self.name][-1].render(False)
        
        s = []
        for x in self.nodes:
            if isinstance(x, BlockNode):
                if x.name in self.content.root.block_vars:

                    s.append(u((self.content.root.block_vars[x.name][-1])))