I'm trying to pass the follwoing
return render('warps.html', query=query)
To a mako template and have it read the query with the follwoing.
<%def name="warps()">
<%
warp = db.warps.find('player' : ${query}).sort(u'player', 1)
print warp
%>
%for x in warp:
${x['player']}, ${x['x_origin']},${x['y_origin']} ${x['x_dest']},${x['y_dest']}<br />
%endfor
</%def>
The ${query}
works fine outside of the <% -- %>
block but within it has to have "" around it. So if I print it i get ${query}
as a string instead of the variable that ${query}
is supposed to represent.
Is there a way to pass a render variable from web.py into the python on a mako template?
It should be:
warp = db.warps.find('player' : query).sort(u'player', 1)
BTW, you shouldn't put logic in the template.