Introduction
Misago uses hybrid approach to its templates. This means every page combines two types of templates to produce final result:
Server-rendered templates: Those templates are .html
files written in Django template language that are rendered on the server when user requests page for first time. They contain links, but there are no forms in them and all buttons they contain are disabled
to prevent interaction.
Client-rendered templates: Those templates are .js
and .jsx
files containing React.js components written in JavaScript. Those templates contain interactivity (buttons, forms, modals) and they use Misago's JSON API for reading and saving data to and from Misago.
Types of templates used varies between pages and UI elements. For example, Misago's navbar is navbar.html
server rendered template with empty <div id="user-menu-mount"></div>
that UserMenu
React.js component fills in when site is displayed by user's browser. Likewise user options section is almost completely done in React.js, with little HTML template telling user to enable JavaScript to change their options. On extreme end there are threads and user profile templates, where nearly whole temple exists in both HTML and JavaScript version.
Note: This approach was great for speed back when it was originally implemented years ago, but its tiresome to work with by modern standard. Today React.js framework make it very easy to implement both client and server HTML using React.js components, and my plan is to eventually convert Misago to this model. However this conversion will require what currently appears to be years of work to happen.