3 ms·
<ul> <% for person in db.query("SELECT * FROM people") { %> <li><%= person["name"] %></li> <% } else { %> <li><em>No people foun
by edem 13y ago
<ul>
<% for person in db.query("SELECT * FROM people") { %>
<li><%= person["name"] %></li>
<% } else { %>
<li><em>No people found!</em></li>
<% } %>
</ul>
I don't think that mixing view and model code in an example is a good idea. The reason is that it encourages mixing different concepts / abstraction levels which will result in confusion and maintainability issues in the long run.
For example if you happen to change the table name from people to humans you will have to change all code which uses people. It is not probable but it might happen.
If your language is not intended to be used for more than a few lines scripts then just ignore my comment.
- RossM 13y agoI think it's a pretty good example to show that it supports the same embeddable-ness of PHP (which is great for prototyping).
- Skoofoo 13y agoIf this project used Ruby, it would be an approachable tool for back-end web development neophytes to learn with before moving on to Sinatra and Rails.
- Segmentation 13y agoIt's just a concise example to demonstrate template and logic at the same time. Introductory PHP looks like that. No where is he writing "Okay, let's start with an example on how you should be coding."
- codezero 13y agoI'm glad they mention this on the main page: HTML escaping by default Otherwise this example would make me even more uneasy :)