Skip to content

Commit 630232f

Browse files
committed
Add string filter for template rendering
1 parent 8b8106a commit 630232f

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

development/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.10-slim-buster
1+
FROM python:3.12-slim
22

33
ENV PYTHONUNBUFFERED 1
44
ENV PYTHONDONTWRITEBYTECODE 1

netbox_config_diff/templates/netbox_config_diff/configcompliance/data.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{% extends base_template %}
22
{% load static %}
3+
{% load string_filters %}
34

45
{% block content %}
56
<div class="row mb-3">
@@ -73,7 +74,7 @@ <h2 class="card-header">Diff
7374
stickyFileHeaders: false,
7475
drawFileList: false,
7576
};
76-
const jsonDiff = `{{ instance.diff|escapejs|safe }}`;
77+
const jsonDiff = `{{ instance.diff|escapejs|safe|replace:'${,\${' }}`;
7778
var targetElement = document.getElementById('diffElement');
7879
var diff2htmlUi = new Diff2HtmlUI(targetElement, jsonDiff, configuration);
7980
diff2htmlUi.draw();

netbox_config_diff/templatetags/__init__.py

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from django import template
2+
3+
register = template.Library()
4+
5+
6+
@register.filter
7+
def replace(value: str, arg: str) -> str:
8+
old, new = arg.split(",")
9+
10+
return value.replace(old, new)

0 commit comments

Comments
 (0)