I've been looking at your example:
I don't understand why lines 9 and 10 in the HTML view are repeated for each row. Shouldn't that be done once only!? Sure, with just 4 records in the table it is not an issue. But for larger databases or more complex calculation/action wasted server resources are significant.