We're all whitespace snobs here ;-).
This is really the one major inability of Haml that still exists.
Currently, no language feature exists to specify that you don't want
whitespace. This will be fixed by version 2.0, but currently no such fix
exists.
I think the best solution for the time being is writing a helper (this
may actually be what we end up doing in the end). Something like
def strip_whitespace(&haml)
capture_haml(&haml).gsub(\s*(<|>)\s*\, '\1')
end
which you would then call with
%ul
= strip_whitespace do
%li one
%li two
%li three
Note that that helper is totally untested and may not work at all. But
with some tweaking it should be fine.
- Nathan
tshim wrote:
> Is there a way to suppress line breaks in haml?
>
> So let's say you've got an inline list you're using as a horizontal
> menubar.
>
> %ul
> %li one
> %li two
> %li three
>
> resulting in
>
> <pre>
> <ul>
> <li>one</li>
> <li>two</li>
> <li>three</li>
> </ul>
> </pre>
>
> Well, what you really want is
> <pre>
> <ul>
> <li>one</li><li>two</li><li>three</li>
> </ul>
> </pre>
>
> because Firefox and Safari treat line breaks between inline elements
> as spaces. So in ie the items are adjacent to eachother, and in other
> browsers there exists a space between each element.
>
> It would be great to have something like a - (dash) character at the
> end of a line that indicates to haml that it should not render a
> newline before rendering the next element.
>
> Or have I spaced out an missed a similar feature in the doco?
>
> Thanks for taking the time to read this. A true whitespace snob I am.
>
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---