Answer the question
In order to leave comments, you need to log in
How to display in html a list passed from python?
There is a function that calls render_template of a template with three parameters
def docs():
page_title = 'Используемая документация'
content_title = 'Используемая документация'
content_text = [
"https://getmdl.io/components/ - Документация по Material Design by Google",
"http://flask.pocoo.org/docs/1.0/ - Документация по Flask"
]
content_text = "<br/>".join([str(elem) for elem in content_text])
return render_template('template.html', title=page_title, pagename=content_title, content=content_text)
{% extends 'base.html' %}
{% block title %}
{{ title }}
{% endblock %}
{% block content_title %}
{{ pagename }}
{% endblock %}
{% block content %}
{{ content }}
{% endblock %}
Answer the question
In order to leave comments, you need to log in
you can use cycles in templates, just pass the list to the template, why construct lines in the code
def docs():
page_title = 'Используемая документация'
content_title = 'Используемая документация'
content_text = [
"https://getmdl.io/components/ - Документация по Material Design by Google",
"http://flask.pocoo.org/docs/1.0/ - Документация по Flask"
]
return render_template('template.html', title=page_title, pagename=content_title, content=content_text)
{% extends 'base.html' %}
{% block title %}
{{ title }}
{% endblock %}
{% block content_title %}
{{ pagename }}
{% endblock %}
{% block content %}
{% for elem in content %}
{{elem}}<br>
{% endfor %}
{% endblock %}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question