Search code examples
templatestornado

Skip serverside rendering in tornado


The syntax of tornado template engine is {{varName}} which incidentally matched with the Angular's data binding syntax.

Is there any decent way to skip server-side rendering of tornado template engine? Changing in HTML file with a new syntax will mess the project a lot.


Solution

  • The easiest possible way would be to not use self.render. Instead, open the file and use self.write to serve it:

    class MyRequestHandler(...):
        def get(self):
            with open('path/to/template.html') as f:
                self.write(f.read())