diff --git a/examples/templates/_layout.html.j2 b/examples/templates/_layout.html.j2 index ac9d804e549115b16ab459072291af19e6623c70..9056e07520d54ff3e8746d259bcbabb3d4ced800 100644 --- a/examples/templates/_layout.html.j2 +++ b/examples/templates/_layout.html.j2 @@ -1,3 +1,4 @@ +{%- set schild = schild | default(None) -%} <!doctype html> <html lang="{% block lang %}de{% endblock %}"> <head> diff --git a/examples/templates/image-left.html.j2 b/examples/templates/image-left.html.j2 index aa4c93c9cd8fd7dc62caba8e24ce387864565473..7ef37637dbeb51450501003f776c9a759bbd1d19 100644 --- a/examples/templates/image-left.html.j2 +++ b/examples/templates/image-left.html.j2 @@ -5,10 +5,16 @@ {% endblock title %} {%- block content -%} <div class="container"> - <img id="image" src="{{ url_for('instance.static', - filename=schild.image) if schild.image else 'placeholder' }}" /> + <img + id="image" + {% if schild.image -%} + src="{{ url_for('instance.static', filename='img/'+schild.image) }}" + {%- else -%} + src="{{ url_for('instance.static', filename='img/sample.png') }}" + {%- endif -%} + /> <p id="text"> - {{ schild.text|default("Inhalt") }} + {{ schild.text|default(lipsum(n=1, min=5, max=10)) }} </p> </div> {% endblock content %} diff --git a/examples/templates/text-only.html.j2 b/examples/templates/text-only.html.j2 index c65bf7634b9a7dfdc2cb6c3374696e3c35a4d3d9..4f51c291906768657f029ea8da064bf38e2bb7d9 100644 --- a/examples/templates/text-only.html.j2 +++ b/examples/templates/text-only.html.j2 @@ -6,7 +6,7 @@ {%- block content -%} <div> <p id="text"> - {{ schild.text|default("Inhalt") }} + {{ schild.text|default(lipsum(n=2, min=5, max=10)) }} </p> </div> {% endblock content %} diff --git a/schilder2000/instance.py b/schilder2000/instance.py index 9f59e75788b72cefae4f757442421d60048ff769..adef3a19e93bfff48be7c9340a74ff94a31734d6 100644 --- a/schilder2000/instance.py +++ b/schilder2000/instance.py @@ -2,7 +2,6 @@ from . import db from .models import Schild from .helpers import Blueprint, get_template_attribute -import textwrap from flask import url_for @@ -31,13 +30,8 @@ def schild_pdf(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") - ) + return bp.render_template(template) + @bp.route("/sample/<template>.pdf") def sample_pdf(template):