Reputation: 2114
Whenever a rails variable equals nil (or actually whenever i use rails code (see 3rd code sample)) i get a string of empty characters in my html.
new.html.haml
%h1.editable.editable_title_field{:contenteditable => 'true', :placeholder => "title"}
= @post_title //@post_title.present? returns false
%h4.editable.editable_subtitle_field{:contenteditable => 'true', :placeholder => "subtitle"}
= @post.subtitle
%p.editable.editable_intro_field{:contenteditable => 'true', :placeholder => "intro"}
= @post.intro
this results in:
i checked, and even:
%h1.editable.editable_title_field{:contenteditable => 'true', :placeholder => "title"}
- @post_title
and:
%h1.editable.editable_title_field{:contenteditable => 'true', :placeholder => "title"}
-
ends up the same as in attached image
because of those empty characters :empty
css selector treats the element as if it was not empty and doesnt append content specified in :before
how do i get rid of those empty characters inside my html tags?
EDIT
screencast of this behavior: http://quick.as/jqlaiorq
Upvotes: 1
Views: 331
Reputation: 6834
Try it with a <
on the end of the %h1
line:
%h1.editable.editable_title_field{:contenteditable => 'true', :placeholder => "title"}<
= @post_title
See the whitespace removal info in the HAML documentation.
Upvotes: 1