The Problem:

Let's say you have an instance variable, @blog_post, and you want to
show it in a <pre> tag:

%pre~ @blog_post

In this case, even though the ~ operator was used, the @blog_post
contents are indented using white space.  The reason for this is that
the find_and_preserve method (~) only works when the content you're
evaluating contains a <textarea>, <pre> or <code> tag.

I was pointed towards the preserve function, and it doesn't seem to
work in this case either:

%pre= preserve(@blog_post)

In this case, the new lines in @blog_post are converted to &#x000A;.
However, if @blog_post is longer than Haml::Buffer::ONE_LINER_LENGTH,
Haml indents it as well.


Out there thought:

While pondering all of this, I wondered to myself: is there a case
where someone would actually want white space inside a <textarea>,
<pre> or <code> tag?  I certainly can't think of any.  I think the
default behavior for these tags should be to _never_ process white
space within them.

Maybe Haml shouldn't even have the ~ operator at all?  If it could be
made smart enough to never add white space to tags where it matters,
and I believe it could, programmers wouldn't have to worry about
whether a tag needs white space or not, it would always just be there
except when it isn't appropriate.

I think this would make learning Haml much easier, because it's
another thing people don't have to worry about.

Thoughts?


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to