garterbelt 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.8
1
+ 0.0.9
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{garterbelt}
8
- s.version = "0.0.8"
8
+ s.version = "0.0.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kane Baccigalupi"]
@@ -46,6 +46,7 @@ Gem::Specification.new do |s|
46
46
  "spec/integration/expectations/general_view.html",
47
47
  "spec/integration/expectations/render_styles/compact.html",
48
48
  "spec/integration/expectations/render_styles/minified.html",
49
+ "spec/integration/expectations/render_styles/pretty_with_embeds.html",
49
50
  "spec/integration/expectations/render_styles/text.html",
50
51
  "spec/integration/expectations/unescaping_view.html",
51
52
  "spec/integration/expectations/variables/view_with_user_and_params.html",
@@ -55,6 +56,7 @@ Gem::Specification.new do |s|
55
56
  "spec/integration/expectations/view_with_tags.html",
56
57
  "spec/integration/integration_spec.rb",
57
58
  "spec/integration/templates/form.rb",
59
+ "spec/integration/templates/pretty_with_embeds.rb",
58
60
  "spec/integration/templates/unescaping_view.rb",
59
61
  "spec/integration/templates/view_partial_nest.rb",
60
62
  "spec/integration/templates/view_with_cache.rb",
@@ -94,6 +96,7 @@ Gem::Specification.new do |s|
94
96
  "spec/garterbelt_spec.rb",
95
97
  "spec/integration/integration_spec.rb",
96
98
  "spec/integration/templates/form.rb",
99
+ "spec/integration/templates/pretty_with_embeds.rb",
97
100
  "spec/integration/templates/unescaping_view.rb",
98
101
  "spec/integration/templates/view_partial_nest.rb",
99
102
  "spec/integration/templates/view_with_cache.rb",
@@ -19,18 +19,20 @@ module Garterbelt
19
19
  str
20
20
  end
21
21
 
22
- def line_end
23
- [:pretty, :text].include?(style) ? "\n" : ''
22
+ def escaped_content
23
+ if escape
24
+ str = ERB::Util.h(content)
25
+ if style == :pretty
26
+ str = str.wrap(Garterbelt.wrap_length, :indent => indent)
27
+ end
28
+ str
29
+ else
30
+ content
31
+ end
24
32
  end
25
33
 
26
34
  def template
27
- str = escape ? ERB::Util.h(content) : content
28
-
29
- if style == :pretty
30
- "#{str.wrap(Garterbelt.wrap_length, :indent => indent)}#{line_end}"
31
- else
32
- "#{str}#{line_end}"
33
- end
35
+ "#{escaped_content}#{line_end}"
34
36
  end
35
37
  end
36
38
  end
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html>
3
+ <head>
4
+ <script type="text/javascript">
5
+ alert("foo");
6
+ alert("bar");
7
+ var foo = 'foo';
8
+ </script>
9
+ <style type="text/css">
10
+ body { background-color: blue;}
11
+ p { background-color: white;}
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <p>
16
+ Style me up!
17
+ </p>
18
+ </body>
19
+ </html>
@@ -1,2 +1,3 @@
1
- You should check out my rad new site:<br> <a class="user_generated_link"
2
- href="http://foo.com">http://foo.com</a><br> It will blow your mind!
1
+ You should check out my rad new site:<br>
2
+ <a class="user_generated_link" href="http://foo.com">http://foo.com</a><br>
3
+ It will blow your mind!
@@ -74,5 +74,9 @@ describe Garterbelt::View, "Integration" do
74
74
  it 'does text only' do
75
75
  ViewWithContentTags.new.render(:style => :text).should == file("render_styles/text")
76
76
  end
77
+
78
+ it 'styles do not screw up text line breaks, especially with raw text embeds' do
79
+ PrettyWithEmbeds.new.render.should == file('render_styles/pretty_with_embeds')
80
+ end
77
81
  end
78
82
  end
@@ -0,0 +1,25 @@
1
+ class PrettyWithEmbeds < Garterbelt::Page
2
+ def head
3
+ script 'type' => 'text/javascript' do
4
+ [
5
+ 'alert("foo");',
6
+ "alert(\"bar\");\nvar foo = 'foo';"
7
+ ].each do |js|
8
+ raw_text js
9
+ end
10
+ end
11
+
12
+ style 'type' => 'text/css' do
13
+ [
14
+ "body { background-color: blue;}",
15
+ "p { background-color: white;}"
16
+ ].each do |css|
17
+ raw_text css
18
+ end
19
+ end
20
+ end
21
+
22
+ def body
23
+ p "Style me up!"
24
+ end
25
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: garterbelt
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 9
10
+ version: 0.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kane Baccigalupi
@@ -243,6 +243,7 @@ files:
243
243
  - spec/integration/expectations/general_view.html
244
244
  - spec/integration/expectations/render_styles/compact.html
245
245
  - spec/integration/expectations/render_styles/minified.html
246
+ - spec/integration/expectations/render_styles/pretty_with_embeds.html
246
247
  - spec/integration/expectations/render_styles/text.html
247
248
  - spec/integration/expectations/unescaping_view.html
248
249
  - spec/integration/expectations/variables/view_with_user_and_params.html
@@ -252,6 +253,7 @@ files:
252
253
  - spec/integration/expectations/view_with_tags.html
253
254
  - spec/integration/integration_spec.rb
254
255
  - spec/integration/templates/form.rb
256
+ - spec/integration/templates/pretty_with_embeds.rb
255
257
  - spec/integration/templates/unescaping_view.rb
256
258
  - spec/integration/templates/view_partial_nest.rb
257
259
  - spec/integration/templates/view_with_cache.rb
@@ -319,6 +321,7 @@ test_files:
319
321
  - spec/garterbelt_spec.rb
320
322
  - spec/integration/integration_spec.rb
321
323
  - spec/integration/templates/form.rb
324
+ - spec/integration/templates/pretty_with_embeds.rb
322
325
  - spec/integration/templates/unescaping_view.rb
323
326
  - spec/integration/templates/view_partial_nest.rb
324
327
  - spec/integration/templates/view_with_cache.rb