iteracion 2
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
def process_file(filepath):
|
||||
with open(filepath, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
if '{{ form.as_p }}' in content:
|
||||
# replace {{ form.as_p }} with {% include 'partials/_form_grid.html' %}
|
||||
content = content.replace('{{ form.as_p }}', '{% include "partials/_form_grid.html" %}')
|
||||
|
||||
# also try to add modern-form class to <form>
|
||||
# match <form ...> that doesn't have class="modern-form"
|
||||
content = re.sub(r'<form\s+method="post"(?!.*?class="modern-form")', r'<form method="post" class="modern-form"', content)
|
||||
|
||||
with open(filepath, 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
print(f"Updated {filepath}")
|
||||
|
||||
for root, dirs, files in os.walk('templates'):
|
||||
for file in files:
|
||||
if file.endswith('.html') and file != '_form_grid.html':
|
||||
process_file(os.path.join(root, file))
|
||||
Reference in New Issue
Block a user