Skip to content
Snippets Groups Projects
Commit 32596c9e authored by Thomas Schneider's avatar Thomas Schneider
Browse files

instance: Add sample (template) preview

parent 2ad0c556
Branches
Tags
No related merge requests found
...@@ -2,6 +2,8 @@ from . import db ...@@ -2,6 +2,8 @@ from . import db
from .models import Schild from .models import Schild
from .helpers import Blueprint, get_template_attribute from .helpers import Blueprint, get_template_attribute
import textwrap
from flask import url_for from flask import url_for
from flask_weasyprint import render_pdf from flask_weasyprint import render_pdf
...@@ -27,6 +29,21 @@ def schild_pdf(ident): ...@@ -27,6 +29,21 @@ def schild_pdf(ident):
return render_pdf(url_for(".schild_html", ident=ident)) return render_pdf(url_for(".schild_html", ident=ident))
@bp.route("/sample/<template>.html")
def sample_html(template):
lipsum = textwrap.dedent("""
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.
""")
return bp.render_template(
template, schild=dict(title="Überschrift", text=lipsum, image="sample.png")
)
@bp.route("/sample/<template>.pdf")
def sample_pdf(template):
return render_pdf(url_for(".sample_html", template=template))
def list_templates(): def list_templates():
schild = Schild() schild = Schild()
loader = bp.jinja_loader loader = bp.jinja_loader
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment