-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples_json_maker.py
53 lines (49 loc) · 1.45 KB
/
examples_json_maker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import json
from src.durctoo.forms import FormGenerator
from src.durctoo.templates import MaterializeFormTemplate
example_form_json = {
"form": {
"form_header": {
"form_id": "example_form",
"method": "POST",
"action": "/submit",
"enctype": ""
},
"form_element_list": [
{
"type": "input",
"input_type": "text",
"name": "name",
"label": "Name",
"required": True,
"placeholder": "Enter your name"
},
{
"type": "select",
"name": "color",
"label": "Favorite Color",
"required": True,
"options": [
{
"value": "red",
"label": "Red"
},
{
"value": "green",
"label": "Green"
},
{
"value": "blue",
"label": "Blue"
}
]
}
]
}
}
form_generator = FormGenerator(example_form_json, MaterializeFormTemplate)
generated_form = form_generator.generate_form()
print("Generated Materialize Form:")
print(generated_form)
with open("example_output/materialize_form.html", "w") as f:
f.write(generated_form)