import re with open('templates/expenses/expense_form.html', 'r', encoding='utf-8') as f: content = f.read() # 1. Add x-data content = content.replace('
', '') # 2. Add x-show to responsible person container content = content.replace('
', '
') # Replace the giant vanilla JS around line 875 script_pattern = re.compile(r'', re.DOTALL) alpine_script = """ """ content = script_pattern.sub(alpine_script, content) with open('templates/expenses/expense_form.html', 'w', encoding='utf-8') as f: f.write(content)