Skip to content

Commit

Permalink
appropriate line breaks for text style
Browse files Browse the repository at this point in the history
  • Loading branch information
baccigalupi committed Apr 15, 2011
1 parent 553dd3b commit a374fc6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/renderers/closed_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion lib/renderers/content_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion spec/renderers/content_tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a374fc6

Please sign in to comment.