Open EricsonWillians opened 8 years ago
I am particularly not a fan of delimiters in templating engines, they can get the code polluted very quickly when used in large files.
I was thinking in a "pre-processor" kind of thing more than a proper language, which would be based on directives, and some prefix for variables (like "@" or "$") for faster typing. A quick example:
<div class="content">
#for @user in @users
<div class="user" id="user-@user.id">
<h1>@user.name</h1>
<p>@user.email</p>
#if @user.has_friends
#include "friends-list.html"
#else
<p>No friends :(</p>
#endif
</div>
#endfor
</div>
This would not allow arbitrary python code inside the template, giving up of some functionality. But it can be good both for security and for separation of concerns (the application's logic should go in a controller or something like that).
I agree that this approach is far more secure. We could use the "WebPage" class (Or some subclass) to "preprocess" it (Load the html file with ServerResource, and use BeautifulSoup to make the necessary changes (We can use it to find the directives as well)). Anyway, a WebPage would be the final result.
We must provide a decent templating engine for Amazonia, and here we shall discuss our approaches in solving this complex problem.