Tornado – Template – Extends


With the background of Tornado-Templates let’s solve bigger problems in web development. It maybe less complex to change welcome messages or usernames on a home page of the website, but it’s not so easy to cater to customization. For instance, gmail web client provides Settings and Themes that are customized for users. Even thought the base template (mail format, mail importance or chat pane) is same, Themes may differ based on customization set by the user.

Handling of customize is really trivial with Tornado. Here’s how..

In the above example, when custom.html is loaded, templateinheritance.html is first loaded as custom.html extends it. templateinheritance.html acts as a base template. {% block header %} and {% end %} block ensures customized information for username=John is addressed on the web page. So, with the base template, only the articles available for reading are shown but with custom.html ensures that when John logs-in he also gets to see the books he has read.

Base Template


Extended Template

Advertisements

One thought on “Tornado – Template – Extends

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s