Rendering Jinja Templates¶
Added in version 2.4.0
Nautobot provides a built-in Jinja2 templating engine that can be used to render templates using Nautobot data. This is useful for generating configuration files, reports, or any other text-based output that can be generated from a template. Nautobot uses Jinja2 to render text for multiple features such as Job Buttons, Custom Links, Webhooks, External Integrations, and more. It's also used by some Nautobot Apps, for example Golden Config uses Jinja2 to render configuration templates.
REST API¶
It's possible to render Jinja2 templates via the Nautobot REST API. You can use the POST /api/core/render-jinja-template/
endpoint to render a template using Nautobot's Jinja2 environment. The request body should include the template content and the context data to render the template.
UI¶
There is also a UI for rendering Jinja2 templates in the Nautobot web interface. You can access it by navigating to /render-jinja-template/
or by clicking the "Jinja Renderer" link in the footer of any Nautobot page. The UI provides a form where you can enter the template content and the context data to render the template.
When rendering Jinja templates through the REST API endpoint or UI, the template will have access to all Django-provided Jinja2 filters, Nautobot-specific filters, and any custom filters that have been registered in the Django Jinja2 environment.