https enforcement

This commit is contained in:
Henrik Jess
2024-12-16 17:04:06 +01:00
parent ce74aa5113
commit f13aa9ec7e
10 changed files with 94 additions and 3013 deletions

View File

@@ -41,6 +41,37 @@ def warning(content):
</div>
'''
def slider(options, images):
"""Render a slider using the provided HTML structure."""
width = options.get("width", 500)
height = options.get("height", 375)
# First image with a <figure> and <figcaption>
first_image_html = f'''
<figure class="relative my-0 slider-bg">
<img src="{images[0]}" width="{width}" height="{height}">
<figcaption class="absolute inset-0 flex flex-col justify-end p-6">
<h1 class="my-0">Fylgja CSS Slider</h1>
</figcaption>
</figure>
'''
## Todo: https://codepen.io/dp_lewis/pen/WNZQzN
# Remaining images as plain <img> tags
other_images_html = "".join([
f'<img src="{img}" width="{width}" height="{height}">' for img in images[1:]
])
# Final combined HTML
return f'''
<main>
<div class="scroll-slider hide-scrollbar">
{first_image_html}
{other_images_html}
</div>
</main>
'''
def create_jinja_environment():
"""Create and configure the Jinja2 environment."""
env = Environment(loader=DictLoader({"base_template": "{{ content | safe }}"}))
@@ -50,6 +81,7 @@ def create_jinja_environment():
"note": note,
"warning": warning,
"link_to": link_to,
"slider": slider,
})
return env