Skip to content

Add Stringify Filter for Jinja2 Rendering#9

Merged
httpdss merged 2 commits into
mainfrom
stringify
Sep 18, 2024
Merged

Add Stringify Filter for Jinja2 Rendering#9
httpdss merged 2 commits into
mainfrom
stringify

Conversation

@httpdss
Copy link
Copy Markdown
Owner

@httpdss httpdss commented Sep 18, 2024

This pull request introduces a new stringify filter to the Jinja2 templating engine, enhancing the flexibility and cleanliness of variable rendering within templates.

Changes:

  • Added stringify filter:
    • Implemented a function that converts strings to lowercase, replaces spaces with hyphens, and removes non-alphanumeric characters.
    • This filter was added to filters.py and integrated into the Jinja2 environment in template_renderer.py.

Justification:

The stringify filter ensures that dynamically generated variable names are formatted in a consistent, URL-safe, and readable way, which is especially useful when rendering template values for deployment configurations.

Impact:

  • Allows for better variable handling and formatting in Jinja2 templates, improving the clarity and reliability of dynamically generated content.

@httpdss httpdss changed the title feat: Add support for stringifying strings on template Add Stringify Filter for Jinja2 Rendering Sep 18, 2024
@httpdss httpdss self-assigned this Sep 18, 2024
@httpdss httpdss marked this pull request as ready for review September 18, 2024 18:19
@httpdss httpdss merged commit 80dceb0 into main Sep 18, 2024
@httpdss httpdss deleted the stringify branch September 18, 2024 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant