On Sun, Aug 2, 2009 at 15:14, Julian Burgess <[email protected]> wrote:
> > ... every time the first letter of the list item is different > from the previous one I want to close the list, create a <h2> for that > letter and then restart the list. > > http://pastie.org/568579 That's how you think when writing ERB, but Haml doesn't let you mess with outer structure from inside loops. Theoretically you could change indentation and write out a "</ul><h2>...</h2><ul>" using haml helpers<http://haml-lang.com/docs/yardoc/Haml/Helpers.html>such as `tab_down`, `haml_concat` and `tab_up`, but actually writing that code would make your template hard to look at and understand. The real solution is to partition your items by first letter before you start looping. Fortunately, ActiveSupport provides us with neat ways of doind this. Here's some code that should be self-explanatory: http://pastie.org/568908 Notice how the Haml template is even cleaner than it would be in ERB. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Haml" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/haml?hl=en -~----------~----~----~----~------~----~------~--~---
