Frequently one wants to treat the first and/or last items in a list differently from the others. is there a way to do that using mustache? what about row striping?
(Obv
I recommend doing both of these with pure css/css3, no js required! This seems ideal when the stuff you're trying to do is not dealing with content. The future is now!:
use nth-child();
http://dev.opera.com/articles/view/zebra-striping-tables-with-css3/
This won't display for ie7 and ie8 ( http://caniuse.com/#search=nth-child ), but they still get the content, so I consider it a win.
#nav li + li + li{
// Crazy styles on the 3rd li here!
}
(has good support: http://caniuse.com/#search=sibling )
Use :last-child.
div#test p:last-child {color: red;}
div#test p:first-child {text-decoration: underline;}
:last-child isn't supported in ie7 and ie8 ( http://caniuse.com/#search=last-child ), so be careful that you're doing something that would degrade gracefully here. Strangely, :first-child is, so it's possible you can, say, put coloring on all elements by default and then explicitly remove them from the first child, and that will actually work in all browsers.