Displaying Mongodb Documents With Html
Solution 1:
Looking over the documentation for the bottle template engine, it looks like you can use 'ifs' and 'fors' to accomplish this.
For instance, if you order is stored at rows['orders'] and you don't know how many there are, in your template you can place:
%for item in rows['orders']:
<td>{{item}}</td>
%end
or say that you need to display a special warning if your customer is ordering an item that is frequently on backorder, and you've passed in another variable, 'backorder', that specifies this:
%if backorder:
<span>This item is frequently on backorder</span>
%end
I haven't tested either of these, but I've done similar things using the Django and Flask template engines. I pulled these samples from here:
http://bottlepy.org/docs/dev/tutorial.html#templates
and the 'Bottle Template to Format the Output' section here:
http://bottlepy.org/docs/dev/tutorial_app.html#using-bottle-for-a-web-based-todo-list
Hope this helps!
Post a Comment for "Displaying Mongodb Documents With Html"