Converter 2: Convert ThinkPhp template to Django template, thinkphpdjango
I wrote a ThinkPhp template to Flask template the day before yesterday.
He was despised by his colleagues because he used Django. I used Flask to avoid him from continuing to use the power of Amway Django. I decided to write a Django template converter.
In order to reuse the code, I had to use inheritance. I split the original code into three sections and got three converters at once.
Class ConverterTemplateEncoding (object): separators = [('<', '>')] def _ init _ (self): self. match = {'opening': 0, 'closing': 0, 'extra ': 0, 'script': '', 'content':'', 'cache ': '', 'paramator': ()} def convert_tag (self, tag, extra =''): return tag... class ConverterThinkPhp2Jinja (ConverterTemplateEncoding): separators = [('{', '}'), ('_', '_'), ('<', '>'), ('<? ','?> ')] Class ConverterThinkPhp2Django (ConverterThinkPhp2Jinja): pass
What I didn't mean is that the Flask template is almost the same as the Django template, at least I didn't implement it. Haha.
If _ name _ = '_ main _': ConverterThinkPhp2Jinja (). convert_templates ('src', 'dst ')
Source code: converterV0.2.zip