コード例 #1
0
    def includeFile(path, datag={}, datal={}):

        host = os.path.dirname(os.getcwd())
        DS = str("/")
        path = '.'+path

        split = path.split('.')

        fileExists = []
        for x in split:

            #fileExists = str(x)
            fileExists.append(x)
        try:
            dirF = list(filter(None, fileExists))
            template_dir = host + DS + 'views' + DS + dirF[0] + DS
            engine = dirF[1]

            if os.path.isdir(template_dir) == True:
                dataG = datag
                dataL = datal
                html_file_path = os.path.join(template_dir, "%s.html" % engine)

                with open(html_file_path) as html_file:
                    html = html_file.read()
                return HTMLeditor.Template(html).render(**dataG)

            else:
                return "The file {filepath} does not exists.".format(filepath=template_dir)

        except Exception as err:
            log_msg.error(err)
            return err
コード例 #2
0
ファイル: include.py プロジェクト: wassafshahzad/pytonik
    def read_html(self, template_dir, engine, context=[]):

        html_file_path = os.path.join(template_dir, "%s.html" % engine)

        try:
            with open(html_file_path) as html_file:
                html = html_file.read()
            return HTMLeditor.Template(html).render(**context)
        except Exception as err:
            log_msg.error(err)
コード例 #3
0
ファイル: App.py プロジェクト: wassafshahzad/pytonik
    def read_html(self, template_dir, engine, context=[]):

        html_file_path = os.path.join(template_dir, "%s.html" % engine)

        try:
            with open(html_file_path) as html_file:
                html = html_file.read()

            print(
                str('<!-- Pytonik -->\n') +
                HTMLeditor.Template(html).render(**context) +
                str('\n<!-- Pytonik {} -->'.format(Version.VERSION_TEXT)))

        except Exception as err:
            log_msg.error(err)
コード例 #4
0
    def read_html(self, template_dir, engine, context=[]):

        html_file_path = os.path.join(template_dir, "%s.html" % engine)

        try:
            with open(html_file_path, encoding='utf-8') as html_file:
                html = html_file.read()

            return str('<!-- Pytonik -->\n') + HTMLeditor.Template(html).render(**context) + str(
                '\n<!-- Pytonik {} -->'.format(Version.VERSION_TEXT))

        except Exception as err:

            Log(template_dir + DS + engine + str('.html')).error(err)
            return