++ Modo OScuro | Claro via Macros

This commit is contained in:
fenix 2024-02-13 17:45:22 +01:00
parent 9b54135efe
commit 0af69075c2
3 changed files with 24 additions and 1 deletions

View File

@ -1,5 +1,7 @@
{# templates/base.html #} {# templates/base.html #}
{% import "macros.html" as macros %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
@ -15,5 +17,8 @@
{% block content %} {% block content %}
<h1>Welcome to {{ title }}!</h1> <h1>Welcome to {{ title }}!</h1>
{% endblock content %} {% endblock content %}
<footer>
{{ macros.light_or_dark_mode("body") }}
</footer>
</body> </body>
</html> </html>

18
templates/macros.html Normal file
View File

@ -0,0 +1,18 @@
{# templates/macros.html #}
{% macro light_or_dark_mode(element) %}
{% if request.args.get('mode') == "dark" %}
<a href="{{ request.path }}">Cambiamos a Modo Claro</a>
<style>
{{ element }} {
background-color: #212F3C;
color: #FFFFF0;
}
{{ element }} a {
color: #00BFFF !important;
}
</style>
{% else %}
<a href="{{ request.path }}?mode=dark">Cambiamos a Modo Oscuro</a>
{% endif %}
{% endmacro %}

View File

@ -6,7 +6,7 @@
<h1>{{ test_name }} {{ title }}: </h1> <h1>{{ test_name }} {{ title }}: </h1>
<ul> <ul>
{% for student in students %} {% for student in students|sort(attribute="name") %}
<li> <li>
{% if student.score > 80 %} :-) {% else %} :-( {% endif %} {% if student.score > 80 %} :-) {% else %} :-( {% endif %}
<em>{{ student.name }}:</em> {{ student.score }}/{{ max_score }} <em>{{ student.name }}:</em> {{ student.score }}/{{ max_score }}