In app engine there a way to use templates a bit more like php/javascript(document.write)?
for instance i would rather do:
<html>
<python>
print "Hello world"
</python>
</html>
rather than all the {IF } {ELSE } django stuff.
In app engine there a way to use templates a bit more like php/javascript(document.write)?
for instance i would rather do:
<html>
<python>
print "Hello world"
</python>
</html>
rather than all the {IF } {ELSE } django stuff.
You want embedded python in html page for that look into mako (http://www.makotemplates.org/), you don't even need print e.g.
<%inherit file="base.html"/>
<%
rows = [[v for v in range(0,10)] for row in range(0,10)]
%>
<table>
% for row in rows:
${makerow(row)}
% endfor
</table>
<%def name="makerow(row)">
<tr>
% for name in row:
<td>${name}</td>\
% endfor
</tr>
</%def>
it comes with inheritance, Callable blocks, is faster and IMO better than django and any day better than php style stuff.
for mako on GAE see https://code.launchpad.net/~pylons-gae/mako/mako-gae
The simplest way is to use string templates from the standard library.
One of the web programming best practices it to not mix business or page logic with HTML. That's why the templates were created after all, so the code can process the request, call the appropriate logic and prepare the objects used to display the response before any output is made. Why do you want to go the other way around?