Does jinja blocks have a default parameter

Viewed 643

Is there a way to create a default entry, if a block isn't filled?

I have a template with a button that says create.

myTemplate.html:

<a href="#" class="btn">create</a>

Up until now, all pages using this template have used the test create, however now I would like to be able to edit that text from my page.

Usually I would add a block to the template to be overridden by the page:

myTemplate.html:

<a href="#" class="btn">{% block createString %}{% endblock %}</a>

myPage.html:

{% extends "myTemplate.html" %}
{% block createString %}next{% endblock %}

However, for this I would like to have something like a default, so that if I don't have any createString block in the myPage, a default string will be used.

Something like:

myTemplate.html:

<a href="#" class="btn">{% block createString %}{% default %}create
                        {% endblock %}</a>

In the myPage.html the button will say next while in the other files extending myTemplate.html the button will read create.

1 Answers
Related