-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add function to trim whitespaces in export templates via jinja environment settings #17653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
complexity: low
Requires minimal effort to implement
netbox
status: accepted
This issue has been accepted for implementation
type: feature
Introduction of new functionality to the application
Milestone
Comments
Both ConfigTemplate and ExportTemplate inherits from ExportTemplatesMixin In ConfigTemplate there are params/methods like: Idk if it's too much for export templates but would it be great to move such params/functions to ExportTemplatesMixin ? Or modify utilities.jinja2.py ? At least, use the same enviroment creation for both cases. |
jeremystretch
added a commit
that referenced
this issue
Apr 8, 2025
…ia jinja environment settings (#19078) * Create RenderMixin, and unify template_code rendering and exporting * Join migrations * Add DEFAULT_MIME_TE constant * Move RenderMixin to extras.models.mixins, Rename RenderMixin to RenderTemplateMixin * Add render_jinja2 to __all__ * Rename ConfigTemplateFilterForm rendering FieldSet * ConfigTemplate lint * Simplify ExportTemplate get_context * Fix table order, and add fields for translations * Update Serializers * Update forms, tables, graphQL, API * Add extra tests for ConfigTemplate and ExportTemplate * Documentation update * Fix typo * Misc cleanup * Clean up template layouts --------- Co-authored-by: Jeremy Stretch <[email protected]>
jeremystretch
added a commit
that referenced
this issue
Apr 14, 2025
arthanson
pushed a commit
that referenced
this issue
Apr 14, 2025
Merged
jnovinger
added a commit
that referenced
this issue
May 23, 2025
…plates The ability to render nested templates was accidentally removed with the implementation of #17653, which normalized the behavior of various Jinja2 template rendering actions. This fix restores that behavior while retaining the normalized behavior. This fix also includes regression tests to ensure this behavior is not removed accidentally again in the future.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
complexity: low
Requires minimal effort to implement
netbox
status: accepted
This issue has been accepted for implementation
type: feature
Introduction of new functionality to the application
NetBox version
3.7.5
Feature type
Change to existing functionality
Proposed functionality
The goal is to achieve feature parity between the [Provisioning --> Config Templates edit] and [Customization --> Export Templates dialog]. In config templates it is possible to use jinja environment parameters, in export templates it is not.
It's also the same behavior in Netbox v4.1.2 (checked via demo application).
Use case
I'm currently implementing a custom export template, which exports prefixes, their assigned VLANs and some custom fields. I'm aware that part of this, is also achievable via the csv export function, but I want to add some semantic sugar via the power of Jinja, like adding first host address, last host address, ...
The messy white space handling with jinja, unfortunately destroys the formatting of the csv.
Database changes
None required?
External dependencies
None?
The text was updated successfully, but these errors were encountered: