<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.
If 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.
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.