cells-erb 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 005beea2b9096c5a67fb46b5ca628b0311b18914
4
- data.tar.gz: c06f9882697cf8817093305196e5e151d4726636
3
+ metadata.gz: 4bb2e8a877505bb6ec775dc3b2a9831da1c4788c
4
+ data.tar.gz: 46a65db846ce908de66f34fa9fc0f843dfd7a58c
5
5
  SHA512:
6
- metadata.gz: f208dccb628772160dd64132d4c981c59bf4a8cfbb8d06e9cadf7797d2b531ba80f0ce1b4fff3ca9a71df809b8ee870617e024100c06e2b299392ab291c2190b
7
- data.tar.gz: 9bc78f5239748dcaa02bc90a6d70df1f772687a7185004ea451fcce4ecf9679682225b4d3561d897c044851577479fa32a38926ad1e85c836713baf2a4099f2b
6
+ metadata.gz: 122cfd4eab5b6d53a0fa30c61f021b488223855d69a4cd27361a4986d6a7ef9ba9e8ecd7eec6dac2bd60ac85c309ee6c041590b41fc7b79398b442182a2af291
7
+ data.tar.gz: 16aac32c8f6d2e831e0fecfc1992976a58f932f27e2160b441e891019c75f3adb71be06cd3f13b37344ef3c04d5c3d2813962d681115d2f4c459335eea00b8ca
@@ -1,4 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1
4
+
1
5
  gemfile:
2
- - gemfiles/rails4.2-tilt-1.4.gemfile
3
- - gemfiles/rails4.2-tilt-2.0.gemfile
4
- - gemfiles/rails3.2-tilt-1.4.gemfile
6
+ - gemfiles/rails_4.2-tilt-1.4.gemfile
7
+ - gemfiles/rails_4.2-tilt-2.0.gemfile
8
+ - gemfiles/rails_3.2-tilt-1.4.gemfile
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.0.4
2
+
3
+ * Fixed output_buffer issues and more.
4
+
1
5
  # 0.0.3
2
6
 
3
7
  * Added `#capture` helper that doesn't do escaping, in `Cell::Erb`.
data/Gemfile CHANGED
@@ -2,9 +2,9 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in cells-erb.gemspec
4
4
  gemspec
5
- platforms :mri_20, :mri_21 do
6
- gem 'pry-byebug'
7
- end
8
- gem 'cells', github: 'apotonick/cells'
9
- gem 'appraisal'
10
- gem 'minitest-reporters'
5
+
6
+ gem "railties", "~> 4.2.0"
7
+ gem "activemodel"
8
+ gem "minitest", "~> 5.2"
9
+ gem "tilt", "~> 2.0"
10
+ gem "cells", path: "../cells"
data/README.md CHANGED
@@ -29,7 +29,7 @@ class SongCell < Cell::ViewModel
29
29
  end
30
30
  ```
31
31
 
32
- If that doesn't work, [read the docs](http://trailblazerb.org/cells/gems/cells4.html#escaping).
32
+ If that doesn't work, [read the docs](http://trailblazerb.org/gems/cells/cells4.html#html-escaping).
33
33
 
34
34
  ## Dependencies
35
35
 
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_runtime_dependency "cells", "~> 4.0.0.beta3"
22
- spec.add_runtime_dependency "erbse", ">= 0.0.2"
21
+ spec.add_dependency "cells", "~> 4.0.0.beta6"
22
+ spec.add_dependency "erbse", ">= 0.0.2"
23
23
 
24
24
  spec.add_development_dependency "bundler"
25
25
  spec.add_development_dependency "rake"
@@ -4,7 +4,6 @@ source "https://rubygems.org"
4
4
 
5
5
  # gem "cells", :github => "apotonick/cells"
6
6
  #gem "cells", path: "../../cells"
7
- gem "appraisal"
8
7
  gem "railties", "~> 3.2.0"
9
8
  gem "activemodel"
10
9
  gem "minitest", "~> 4.6"
@@ -4,7 +4,6 @@ source "https://rubygems.org"
4
4
 
5
5
  # gem "cells", :github => "apotonick/cells"
6
6
  #gem "cells", path: "../../cells"
7
- gem "appraisal"
8
7
  gem "railties", "~> 4.2.0"
9
8
  gem "activemodel"
10
9
  gem "minitest", "~> 5.2"
@@ -4,7 +4,6 @@ source "https://rubygems.org"
4
4
 
5
5
  #gem "cells", :github => "apotonick/cells"
6
6
  # gem "cells", path: "../../cells"
7
- gem "appraisal"
8
7
  gem "railties", "~> 4.2.0"
9
8
  gem "activemodel"
10
9
  gem "minitest", "~> 5.2"
@@ -4,7 +4,6 @@ source "https://rubygems.org"
4
4
 
5
5
  # gem "cells", :github => "apotonick/cells"
6
6
  #gem "cells", path: "../../cells"
7
- gem "appraisal"
8
7
  gem "railties", "~> 4.2.0"
9
8
  gem "activemodel"
10
9
  gem "minitest", "~> 5.2"
@@ -3,14 +3,46 @@ require "erbse"
3
3
  module Cell
4
4
  # Erb contains helpers that are messed up in Rails and do escaping.
5
5
  module Erb
6
+ # This is to prevent multiple renders to share the same output_buffer.
7
+ # I am still trying to find a way to avoid output buffers.
8
+ def render_template(*)
9
+ old_output_buffer = @output_buffer
10
+ super
11
+ ensure
12
+ @output_buffer = old_output_buffer
13
+ end
14
+
15
+ def template_options_for(options)
16
+ {
17
+ template_class: ::Cell::Erb::Template,
18
+ escape_html: false,
19
+ escape_attrs: false,
20
+ suffix: "erb"
21
+ }
22
+ end
23
+
6
24
  # this is capture copied from AV:::CaptureHelper without doing escaping.
7
- # TODO: re-implement capture and return content instead of the OB rubbish.
8
25
  def capture(*args)
9
26
  value = nil
10
27
  buffer = with_output_buffer { value = yield(*args) }
11
- if string = buffer.presence || value and string.is_a?(String)
12
- string
13
- end
28
+
29
+ return buffer.to_s if buffer.size > 0
30
+ value # this applies for "Beachparty" string-only statements.
31
+ end
32
+
33
+ def with_output_buffer(block_buffer=ViewModel::OutputBuffer.new)
34
+ @output_buffer, old_buffer = block_buffer, @output_buffer
35
+ yield
36
+ @output_buffer = old_buffer
37
+
38
+ block_buffer
39
+ end
40
+
41
+ # Below:
42
+ # Rails specific helper fixes. I hate that. I can't tell you how much I hate those helpers,
43
+ # and their blind escaping for every possible string within the application.
44
+ def content_tag(name, content_or_options_with_block=nil, options=nil, escape=false, &block)
45
+ super
14
46
  end
15
47
 
16
48
  def form_tag_with_body(html_options, content)
@@ -33,21 +65,15 @@ module Cell
33
65
  require_template_library 'erbse'
34
66
  end
35
67
 
36
- # :engine_class can be passed via
37
- #
38
68
  # Tilt.new("#{base}/#{prefix}/#{view}", engine_class: Erbse::Eruby)
39
69
  def prepare
40
- engine_class = options.delete(:engine_class)
41
- # engine_class = ::Erubis::EscapedEruby if options.delete(:escape_html)
42
- @template = (engine_class || ::Erbse::Template).new(data, options)
70
+ @template = ::Erbse::Template.new(data, options)
43
71
  end
44
72
 
45
73
  def precompiled_template(locals)
74
+ # puts "@@@@@ #{@template.().inspect}"
46
75
  @template.call
47
76
  end
48
77
  end
49
78
  end
50
- end
51
-
52
- Tilt.register Cell::Erb::Template, "erb"
53
- # Tilt.prefer Cell::Erb::Template
79
+ end
@@ -1,5 +1,5 @@
1
1
  module Cell
2
2
  module Erb
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -0,0 +1 @@
1
+ <b>Questions: <%= render :render_in_render_2 %></b>
@@ -31,4 +31,8 @@ Weiter!
31
31
  <%= breadcrumbs %>
32
32
 
33
33
  <%= current_page %>
34
- <%= form_tag_with_body( {url: "/rails/escapes/too/much"}, %{<input type="button"/>}).html_safe %>
34
+ <%= form_tag_with_body( {url: "/rails/escapes/too/much"}, %{<input type="button"/>}).html_safe %>
35
+
36
+ <%= form_for OpenStruct.new, url: "/", as: "open" do |f| %>
37
+ <%= f.text_field :id %>
38
+ <% end %>
@@ -4,6 +4,9 @@ class SongCell < Cell::ViewModel
4
4
  include ActionView::Helpers::FormHelper
5
5
  include Cell::Erb
6
6
 
7
+ def protect_against_forgery?
8
+ end
9
+
7
10
  def with_form_tag_and_content_tag
8
11
  render
9
12
  end
@@ -36,6 +39,10 @@ class SongCell < Cell::ViewModel
36
39
  render
37
40
  end
38
41
 
42
+ def render_in_render
43
+ render
44
+ end
45
+
39
46
  private
40
47
  def cap
41
48
  "yay, #{with_output_buffer { yield } }"
@@ -4,9 +4,12 @@ class ErbTest < MiniTest::Spec
4
4
  let (:controller) { ApplicationController.new.tap { |ctl| ctl.send("request=", ActionDispatch::Request.new({})) } }
5
5
  let (:song_cell) { SongCell.new(controller) }
6
6
 
7
+ # render in render
8
+ it { song_cell.(:render_in_render).must_equal "<b>Questions: Yes!</b>" }
7
9
 
8
10
  # URL helpers work in cell instance.
9
- it { song_cell.songs_path.must_equal "/songs" }
11
+ # -- this is actually covered well enough in cells, and is unrelated to ERB.
12
+ # it { song_cell.songs_path.must_equal "/songs" }
10
13
 
11
14
  # content_tag { }
12
15
  it { song_cell.(:with_content_tag).must_equal "<div>Beachparty</div>" }
@@ -27,6 +30,12 @@ class ErbTest < MiniTest::Spec
27
30
  form_with_body_tag = "<form url=\"/rails/escapes/too/much\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"button\"/></form>"
28
31
  form_with_body_tag = "<form method=\"post\" url=\"/rails/escapes/too/much\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /></div><input type=\"button\"/></form>" if ActionPack::VERSION::MAJOR == 3
29
32
 
33
+ form_for_tag = "<form class=\"new_open\" id=\"new_open\" action=\"/\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" />
34
+ <input type=\"text\" name=\"open[id]\" id=\"open_id\" />
35
+ </form>"
36
+ form_for_tag = "<form accept-charset=\"UTF-8\" action=\"/\" class=\"new_open\" id=\"new_open\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /></div>
37
+ <input id=\"open_id\" name=\"open[id]\" size=\"30\" type=\"text\" />
38
+ </form>" if ActionPack::VERSION::MAJOR == 3
30
39
 
31
40
  song_cell.(:with_form_tag_and_content_tag).must_equal %{Word.
32
41
 
@@ -52,7 +61,9 @@ Weiter!
52
61
  <a href=\"/1\">1</a>+<a href=\"/2\">2</a>
53
62
 
54
63
  <b>No current page!<b>
55
- #{form_with_body_tag}}
64
+ #{form_with_body_tag}
65
+
66
+ #{form_for_tag}}
56
67
  end
57
68
  end
58
69
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cells-erb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-26 00:00:00.000000000 Z
12
+ date: 2015-06-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cells
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 4.0.0.beta3
20
+ version: 4.0.0.beta6
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 4.0.0.beta3
27
+ version: 4.0.0.beta6
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: erbse
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -78,7 +78,6 @@ extra_rdoc_files: []
78
78
  files:
79
79
  - ".gitignore"
80
80
  - ".travis.yml"
81
- - Appraisals
82
81
  - CHANGES.md
83
82
  - Gemfile
84
83
  - LICENSE.txt
@@ -93,6 +92,8 @@ files:
93
92
  - lib/cell/erb/version.rb
94
93
  - lib/cells-erb.rb
95
94
  - test/dummy/Rakefile
95
+ - test/dummy/app/cells/song/render_in_render.erb
96
+ - test/dummy/app/cells/song/render_in_render_2.erb
96
97
  - test/dummy/app/cells/song/with_content_tag.erb
97
98
  - test/dummy/app/cells/song/with_content_tag_and_content_tag.erb
98
99
  - test/dummy/app/cells/song/with_form_for_block.erb
@@ -134,6 +135,8 @@ specification_version: 4
134
135
  summary: Tilt binding for Erbse.
135
136
  test_files:
136
137
  - test/dummy/Rakefile
138
+ - test/dummy/app/cells/song/render_in_render.erb
139
+ - test/dummy/app/cells/song/render_in_render_2.erb
137
140
  - test/dummy/app/cells/song/with_content_tag.erb
138
141
  - test/dummy/app/cells/song/with_content_tag_and_content_tag.erb
139
142
  - test/dummy/app/cells/song/with_form_for_block.erb
data/Appraisals DELETED
@@ -1,23 +0,0 @@
1
- appraise 'rails-3.2' do
2
- gem 'railties', '~> 3.2'
3
- gem 'tzinfo'
4
- gem 'minitest', '4.7.5'
5
- end
6
-
7
- appraise "rails-4.0" do
8
- gem 'railties', '~> 4.0.0'
9
- gem 'activemodel'
10
- gem 'minitest', '4.7.5'
11
- end
12
-
13
- appraise "rails-4.1" do
14
- gem 'railties', '~> 4.1.0'
15
- gem 'activemodel'
16
- gem 'minitest', '~> 5.2'
17
- end
18
-
19
- appraise "rails-4.2" do
20
- gem 'railties', '~> 4.2.0'
21
- gem 'activemodel'
22
- gem 'minitest', '~> 5.2'
23
- end