This program is used to generate text from template. It will run python script between <py> </py>
in template.
- Put your template in template.txt
- Put your data in data.py
- Execute generator.py
#Example
template.txt:
public class <py>print class_name,</py> implements Serializable {
private static final String docType = <py>print '"'+doc_type+'";'</py>
<py>
for field in field_list:
print " private " + field[0] + " " + field[1] + ';\n',
</py>
data.py:
class_name = 'AlEvent'
doc_type = 'alEvent'
field_list = [('int','eventId'),('String','stationName')]
Execution output:
@Entity
public class AlEvent implements Serializable {
private static final String docType = "alEvent";
private int eventId;
private String stationName;