Permalink
Browse files

appropriate line breaks for text style

  • Loading branch information...
1 parent 553dd3b commit a374fc6e0fca2e97d20d1b6d71f9df40992b9960 @baccigalupi committed Apr 15, 2011
Showing with 26 additions and 3 deletions.
  1. +5 −1 lib/renderers/closed_tag.rb
  2. +5 −1 lib/renderers/content_tag.rb
  3. +16 −1 spec/renderers/content_tag_spec.rb
@@ -45,7 +45,11 @@ def rendered_attributes
end
def template
- view.render_style == :text ? "" : "#{indent}<#{type}#{rendered_attributes}>#{line_end}"
+ if style == :text
+ type == :br ? "\n" : ""
+ else
+ "#{indent}<#{type}#{rendered_attributes}>#{line_end}"
+ end
end
def render
@@ -33,7 +33,11 @@ def head
end
def foot_template
- style == :text ? '' : "#{indent}</#{type}>#{line_end}"
+ if style == :text
+ [:p, :ul, :ol, :li].include?(type) ? "\n" : ''
+ else
+ "#{indent}</#{type}>#{line_end}"
+ end
end
def foot
@@ -110,10 +110,25 @@
end
describe ':text' do
- it 'has no tags' do
+ before do
@view.render_style = :text
+ end
+
+ it 'has no tags' do
@tag.render.should_not match /<[^>]>*/
end
+
+ [:p, :ul, :ol, :li].each do |type|
+ it ":#{type} includes a line break" do
+ @tag.type = type
+ @tag.render.should match /\n/
+ end
+ end
+
+ it 'has no line breaks othewise' do
+ @tag.type = :div
+ @tag.render.should_not match /\n/
+ end
end
end

0 comments on commit a374fc6

Please sign in to comment.