Ejemplo n.º 1
0
    def __init__(self, template_text, template_fields, template_name='basic'):
        self.template_text = template_text
        self.template_fields = template_fields
        self.template_name = template_name

        self.text_env = app.create_jinja_environment()
        self.text_env.variable_start_string = '%%'
        self.text_env.variable_end_string = '%%'
Ejemplo n.º 2
0
def preview_file(project, filename):
    preview_form = PreviewForm()
    if preview_form.validate_on_submit():
        print preview_form.template_id
        template_id = Template.query.get(preview_form.template_id)
        md_content = preview_form.md_content
        env = current_app.create_jinja_environment()
        template = env.get_template(template_id.filename)
        print template
        return convert_md(md_content, template)
    else:
        return NotFound()
def preview_file(project, filename):
    preview_form = PreviewForm()
    if preview_form.validate_on_submit():
        print preview_form.template_id
        template_id = Template.query.get(preview_form.template_id)
        md_content = preview_form.md_content
        env = current_app.create_jinja_environment()
        template = env.get_template(template_id.filename)
        print template
        return convert_md(md_content, template)
    else:
        return NotFound()
 def save_render_html(self):
     print 'Rendering ({project!s}/{filename!s})'.format(project=self.project, filename=self.filename)
     env = current_app.create_jinja_environment()
     template_file = env.get_template(self.template.filename)
     if self.published:
         html = convert_md(self.md_content, template_file)
     else:
         warn_msg = "This file not published and only visible to UA team."
         html = convert_md(self.md_content, template_file, warning=warn_msg)
     meta = get_md_meta(self.md_content)
     title_known = ''
     if (not "title" in meta or meta["title"] == ''):
         title_known = self.project + "/" + self.filename
     else:
         title_known = meta["title"]
     self.update(html_content = html)
     self.update(title = title_known)
     self.save()
     return
Ejemplo n.º 5
0
 def get_env(self):
     from flask import current_app
     return current_app.create_jinja_environment()
Ejemplo n.º 6
0
 def get_env(self):
     from flask import current_app
     return current_app.create_jinja_environment()