Question

I've only just started using Flask. I have a file with a series of links. It's generated by a separate script that returns something along the lines of this

<li><a href="foo1">foo1 Name </a></li>
<li><a href="foo2">foo2 Name </a></li>
<li><a href="foo3">foo3 Name </a></li>
<li><a href="foo4">foo4 Name </a></li>

which I save in a filewithlinks.html file in the templates folder

I want to do something like this

{% extends "template.html" %}
{% block content %}
<h2>The Links</h2>
<ul>
{% extends "filewithlinks.html">
</ul>
{% endblock %}

but when I try that it throws an error. for the {% extends "filewithlinks.html"> %} Is there a way to do this?

Was it helpful?

Solution

You can only extend one template at a time. For everything else, use macros or include statements.

For your list, using {% include %} is just the ticket:

{% extends "template.html" %}
{% block content %}
<h2>The Links</h2>
<ul>
{% include "filewithlinks.html">
</ul>
{% endblock %}

OTHER TIPS

Use include macro. Replace:

<ul>
    {% extends "filewithlinks.html">
</ul>

with:

<ul>
    {% include 'filewithlinks.html' %}
</ul>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top