move call to action vars to be scoped

This commit is contained in:
c0de 2023-12-29 10:18:03 -06:00
parent 04f860e06a
commit b675961b9c
2 changed files with 21 additions and 19 deletions

View File

@ -11,16 +11,16 @@
- text | yes | none - text | yes | none
... (etc) ... (etc)
#}--> #}-->
{% if active | default(false) %} {% if call_to_action.active | default(false) %}
<section class="py-5 text-center container"> <section class="py-5 text-center container">
<div class="row py-lg-5"> <div class="row py-lg-5">
<div class="col-lg-6 col-md-8 mx-auto"> <div class="col-lg-6 col-md-8 mx-auto">
<h1 class="fw-light">{{ header }}</h1> <h1 class="fw-light">{{ call_to_action.header }}</h1>
<p class="lead text-body-secondary">{{ lead_text }}</p> <p class="lead text-body-secondary">{{ call_to_action.lead_text }}</p>
{% if action_buttons %} {% if call_to_action.buttons %}
<p> <p>
{% for button in action_buttons %} {% for button in call_to_action.buttons %}
<a <a
href="{{ button.href | default('#') }}" href="{{ button.href | default('#') }}"
class="btn btn-{{ button.theme | default('primary') }} my-2 d-inline-flex" class="btn btn-{{ button.theme | default('primary') }} my-2 d-inline-flex"

30
test.py
View File

@ -48,20 +48,22 @@ template_vars = {
"main_line": "Copyright 2024 Code Fox", "main_line": "Copyright 2024 Code Fox",
"extra_lines": ["This is another line", "This is yet another line"], "extra_lines": ["This is another line", "This is yet another line"],
}, },
"active": False, "call_to_action": {
"header": "This is a call to action", "active": True,
"lead_text": "Some interesting text for the user", "header": "This is a call to action",
"action_buttons": [ "lead_text": "Some interesting text for the user",
{"href": "1"}, "buttons": [
{"href": "2", "theme": "danger"}, {"href": "1"},
{"href": "3", "theme": "warning", "icon": "exclamation-diamond-fill"}, {"href": "2", "theme": "danger"},
{ {"href": "3", "theme": "warning", "icon": "exclamation-diamond-fill"},
"href": "3", {
"theme": "warning", "href": "3",
"icon": "exclamation-diamond-fill", "theme": "warning",
"text": "some text", "icon": "exclamation-diamond-fill",
}, "text": "some text",
], },
],
},
"gallery_items": [ "gallery_items": [
{ {
"src": "https://files.c0defox.es/Pictures/arctic-fox.jpg", "src": "https://files.c0defox.es/Pictures/arctic-fox.jpg",