The day before yesterday wrote a "thinkphp template to Flask template"
I was despised by my colleague because he was using Django, and I used flask to avoid being so powerful as he continued to be with the Amway Django. I decided to write a Django template converter.
In order to reuse the code, I had to use inheritance, I divided the original code into three paragraphs, and suddenly got three converters.
classconvertertemplateencoding (object): Separators= [('<','>')] def __init__(self): Self.match= {'opening': 0,'closing': 0,'Extra': 0,'Script':"','content':"','Cache':"','Separator': ()} defConvert_tag (self, tag, extra="'): returntag ...classConverterthinkphp2jinja (convertertemplateencoding): Separators= [('{','}'), ('__','__'), ('<','>'), ('<?','?>')]classConverterthinkphp2django (Converterthinkphp2jinja):Pass
What I did not say is that the flask template is quite similar to the Django template, at least I didn't implement it. Ha.
if __name__ ' __main__ ' : Converterthinkphp2jinja (). Convert_templates ('src'DST ')
Source: Converterv0.2.zip
Converter 2:thinkphp template to Django template