Exemple #1
0
    def __ext_inherit(self, uri):
        """实现继承功能
        :param uri: 
        :return: 
        """
        fpath = self.__get_fpath(uri)
        if not fpath: raise TemplateErr("cannot found inherit template '%s'" % uri)

        fdst = open(fpath, "rb")
        text_content = fdst.read().decode("iso-8859-1")
        fdst.close()

        exeobj = core_execute.execute(**self.__kwargs)
        self.__register_exts(exeobj)

        # 首先生成语法树
        exeobj._gen_syntax_tree(text_content)
        self.__exe_objects.append(exeobj)
Exemple #2
0
    def __ext_inherit(self, uri):
        """实现继承功能
        :param uri: 
        :return: 
        """
        fpath = self.__get_fpath(uri)
        if not fpath: raise TemplateErr("cannot found inherit template '%s'" % uri)

        fdst = open(fpath, "rb")
        text_content = fdst.read().decode("iso-8859-1")
        fdst.close()

        exeobj = core_execute.execute(**self.__kwargs)
        self.__register_exts(exeobj)

        # 首先生成语法树
        exeobj._gen_syntax_tree(text_content)
        self.__exe_objects.append(exeobj)
Exemple #3
0
    def render_string(self, s, **kwargs):
        self.__kwargs = kwargs

        exeobj = core_execute.execute(**kwargs)

        self.__register_exts(exeobj)

        exeobj._gen_syntax_tree(s)
        exeobj_a = exeobj

        while 1:
            try:
                exeobj_b = self.__exe_objects.pop(0)
            except IndexError:
                break

            for k, v in exeobj_a.block_map.items():
                exeobj_b.block_map[k] = v

            exeobj_a = exeobj_b

        exeobj_a._exe()

        return exeobj_a._get_buff_content()
Exemple #4
0
    def render_string(self, s, **kwargs):
        self.__kwargs = kwargs

        exeobj = core_execute.execute(**kwargs)

        self.__register_exts(exeobj)

        exeobj._gen_syntax_tree(s)
        exeobj_a = exeobj

        while 1:
            try:
                exeobj_b = self.__exe_objects.pop(0)
            except IndexError:
                break

            for k, v in exeobj_a.block_map.items():
                exeobj_b.block_map[k] = v

            exeobj_a = exeobj_b

        exeobj_a._exe()

        return exeobj_a._get_buff_content()