cells-haml 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 +4 -4
- data/CHANGES.md +3 -0
- data/README.md +18 -13
- data/cells-haml.gemspec +2 -2
- data/gemfiles/rails_3.2-tilt-1.4.gemfile +1 -4
- data/gemfiles/rails_4.0-tilt-1.4.gemfile +12 -0
- data/gemfiles/rails_4.2-tilt-1.4.gemfile +1 -4
- data/gemfiles/rails_4.2-tilt-2.0-rails-haml-0.9.gemfile +14 -0
- data/gemfiles/rails_4.2-tilt-2.0.gemfile +1 -2
- data/gemfiles/rails_4.2-tilt-3.0.gemfile +1 -2
- data/lib/cell/haml/version.rb +1 -1
- data/lib/cell/haml.rb +14 -80
- data/test/dummy/app/cells/song/with_form_tag_and_content_tag.haml +16 -2
- data/test/dummy/app/cells/song_cell.rb +9 -1
- data/test/haml_test.rb +10 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cdad224d97c15e3ca642dcea8d9449b2b1298ae
|
4
|
+
data.tar.gz: f665747209ac4d5d7cff32d680677b811be68a87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d3d433ac40e0cf825f3bca8a058739faa9bab14ed28f78fa48ff4a35ea38aed4bf7490ec7231367e3ae3135630c1e2f63811c9ef483bdfc87174b82fca5a6ef
|
7
|
+
data.tar.gz: 33413f055c224c4157fe835f97820b59d24caec46c4e7fbf2b7be2bcdf7ad0f1687dc49f378e996174f826aa8a3afe3fb888558608a2cb0a0918e074637330ae
|
data/CHANGES.md
ADDED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Cells::Haml
|
2
2
|
|
3
|
-
|
3
|
+
Haml support for Cells.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -10,22 +10,27 @@ Add this line to your application's Gemfile:
|
|
10
10
|
gem 'cells-haml'
|
11
11
|
```
|
12
12
|
|
13
|
-
|
13
|
+
This will set `ViewModel.template_engine = :haml.
|
14
14
|
|
15
|
-
|
15
|
+
And that's all you need to do.
|
16
16
|
|
17
|
-
|
17
|
+
## HTML Escaping
|
18
18
|
|
19
|
-
|
19
|
+
Cells doesn't escape except when you tell it to do. However, you may run into problems when using Rails helpers. Internally, those helpers often blindly escape. This is not Cells' fault but a design flaw in Rails.
|
20
20
|
|
21
|
-
|
21
|
+
As a first step, try this and see if it helps.
|
22
22
|
|
23
|
-
|
23
|
+
```ruby
|
24
|
+
class SongCell < Cell::ViewModel
|
25
|
+
include ActionView::Helpers::FormHelper
|
26
|
+
include Cell::Haml # include Haml _after_ AV helpers.
|
27
|
+
|
28
|
+
# ..
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
If that doesn't work, [read the docs](http://trailblazerb.org/cells/gems/cells4.html#escaping).
|
24
33
|
|
25
|
-
##
|
34
|
+
## Dependencies
|
26
35
|
|
27
|
-
1.
|
28
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
-
5. Create a new Pull Request
|
36
|
+
This gem works with Tilt 1.4 and 2.0, and hence allows you to use it from Rails 3.2 upwards.
|
data/cells-haml.gemspec
CHANGED
@@ -17,8 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test)/})
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
|
-
spec.
|
21
|
-
spec.
|
20
|
+
spec.add_dependency 'cells', '~> 4.0.0.beta3'
|
21
|
+
spec.add_dependency 'haml', '~> 4.0'
|
22
22
|
spec.add_development_dependency 'bundler'
|
23
23
|
spec.add_development_dependency 'rake'
|
24
24
|
end
|
@@ -3,8 +3,7 @@
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
5
|
#gem "cells", :github => "apotonick/cells"
|
6
|
-
gem "cells", path: "../../cells"
|
7
|
-
gem "appraisal"
|
6
|
+
# gem "cells", path: "../../cells"
|
8
7
|
gem "railties", "~> 3.2.0"
|
9
8
|
gem "activemodel"
|
10
9
|
gem "minitest", "~> 4.0"
|
@@ -12,5 +11,3 @@ gem "tilt", "~> 1.4"
|
|
12
11
|
gem "tzinfo"
|
13
12
|
|
14
13
|
gemspec :path => "../"
|
15
|
-
|
16
|
-
# gem "erbse", path: "../../erbse"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
#gem "cells", :github => "apotonick/cells"
|
6
|
+
# gem "cells", path: "../../cells"
|
7
|
+
gem "railties", "~> 4.0.0"
|
8
|
+
gem "activemodel"
|
9
|
+
gem "minitest", "~> 4.0"
|
10
|
+
gem "tilt", "~> 1.4"
|
11
|
+
|
12
|
+
gemspec :path => "../"
|
@@ -2,14 +2,11 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "cells", :github => "apotonick/cells"
|
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"
|
11
10
|
gem "tilt", "~> 1.4"
|
12
11
|
|
13
12
|
gemspec :path => "../"
|
14
|
-
|
15
|
-
# gem "erbse", path: "../../erbse"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# gem "cells", :github => "apotonick/cells"
|
6
|
+
gem "cells", path: "../../cells"
|
7
|
+
gem "appraisal"
|
8
|
+
gem "railties", "~> 4.2.0"
|
9
|
+
gem "activemodel"
|
10
|
+
gem "minitest", "~> 5.2"
|
11
|
+
gem "tilt", "~> 2.0"
|
12
|
+
gem "haml-rails", "~> 0.9.0"
|
13
|
+
|
14
|
+
gemspec :path => "../"
|
data/lib/cell/haml/version.rb
CHANGED
data/lib/cell/haml.rb
CHANGED
@@ -2,87 +2,21 @@ require 'tilt/haml'
|
|
2
2
|
|
3
3
|
module Cell
|
4
4
|
module Haml
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
# end
|
20
|
-
|
21
|
-
|
22
|
-
# def self.included(base)
|
23
|
-
# base.class_eval do
|
24
|
-
# alias_method :output_buffer_without_haml, :output_buffer
|
25
|
-
# alias_method :output_buffer, :output_buffer_with_haml
|
26
|
-
|
27
|
-
# alias_method :set_output_buffer_without_haml, :output_buffer=
|
28
|
-
# alias_method :output_buffer=, :set_output_buffer_with_haml
|
29
|
-
# end
|
30
|
-
# end
|
31
|
-
|
32
|
-
# # TODO: remove the concept of output buffers and just return block's result!
|
33
|
-
# class OutputBuffer < String
|
34
|
-
# end
|
35
|
-
|
36
|
-
|
37
|
-
# def with_output_buffer(buf = nil)
|
38
|
-
# unless buf
|
39
|
-
# buf = OutputBuffer.new
|
40
|
-
# end
|
41
|
-
# self.output_buffer, old_buffer = buf, output_buffer
|
42
|
-
# yield
|
43
|
-
# output_buffer
|
44
|
-
# ensure
|
45
|
-
# self.output_buffer = old_buffer
|
46
|
-
# end
|
47
|
-
|
48
|
-
|
49
|
-
# # generic ERB HAML HELPERS>>>>>>
|
50
|
-
# def capture(*args,&block)
|
51
|
-
# value = nil
|
52
|
-
# buffer = with_output_buffer() { value = yield(*args) }
|
53
|
-
# if string = buffer.presence || value and string.is_a?(String)
|
54
|
-
# return string
|
55
|
-
# end
|
56
|
-
# end
|
57
|
-
|
58
|
-
# # From FormTagHelper. why do they escape every possible string? why?
|
59
|
-
# def form_tag_in_block(html_options, &block)
|
60
|
-
# content = capture(&block)
|
61
|
-
# form_tag_with_body(html_options, content)
|
62
|
-
# end
|
63
|
-
|
64
|
-
# def form_tag_with_body(html_options, content)
|
65
|
-
# "#{form_tag_html(html_options)}" << content.to_s << "</form>"
|
66
|
-
# end
|
67
|
-
|
68
|
-
# def form_tag_html(html_options)
|
69
|
-
# extra_tags = extra_tags_for_form(html_options)
|
70
|
-
# "#{tag(:form, html_options, true) + extra_tags}"
|
71
|
-
# end
|
72
|
-
|
73
|
-
# # Rails 4.0, TagHelper.
|
74
|
-
# def tag_option(key, value, escape)
|
75
|
-
# super(key, value, false)
|
76
|
-
# end
|
77
|
-
|
78
|
-
# def content_tag_string(name, content, options, escape=true)
|
79
|
-
# super(name, content, options, false)
|
80
|
-
# end
|
5
|
+
# From FormTagHelper. why do they escape every possible string? why?
|
6
|
+
def form_tag_in_block(html_options, &block)
|
7
|
+
content = capture(&block)
|
8
|
+
form_tag_with_body(html_options, content)
|
9
|
+
end
|
10
|
+
|
11
|
+
def form_tag_with_body(html_options, content)
|
12
|
+
"#{form_tag_html(html_options)}" << content.to_s << "</form>"
|
13
|
+
end
|
14
|
+
|
15
|
+
def form_tag_html(html_options)
|
16
|
+
extra_tags = extra_tags_for_form(html_options)
|
17
|
+
"#{tag(:form, html_options, true) + extra_tags}"
|
18
|
+
end
|
81
19
|
end
|
82
20
|
|
83
|
-
# ViewModel.class_eval do
|
84
|
-
# include Haml
|
85
|
-
# end
|
86
|
-
|
87
21
|
ViewModel.template_engine = :haml
|
88
22
|
end
|
@@ -4,12 +4,26 @@ Word.
|
|
4
4
|
= link_to "/rails/sucks" do
|
5
5
|
hallo
|
6
6
|
|
7
|
-
= content_tag(
|
7
|
+
= content_tag(:ul) do
|
8
8
|
Hallo
|
9
9
|
|
10
|
+
- answer = "<script>oui!</script>"
|
11
|
+
|
12
|
+
-# test content rendering in capture.
|
10
13
|
- content = capture do
|
11
14
|
Bonjour!
|
15
|
+
= link_to "Coffee?", "/coffee"
|
16
|
+
<b>Yes please!</b>
|
17
|
+
= answer
|
12
18
|
|
13
19
|
Weiter!
|
14
20
|
|
15
|
-
= content
|
21
|
+
= content
|
22
|
+
|
23
|
+
- breadcrumbs = capture do
|
24
|
+
- [link_to("1", "/1"), link_to("2", "/2")].join("+")
|
25
|
+
|
26
|
+
= breadcrumbs
|
27
|
+
|
28
|
+
= current_page
|
29
|
+
= form_tag_with_body( {url: "/rails/escapes/too/much"}, %{<input type="button"/>})
|
@@ -2,6 +2,7 @@ class SongCell < Cell::ViewModel
|
|
2
2
|
self.view_paths = ["test/dummy/app/cells"]
|
3
3
|
|
4
4
|
include ActionView::Helpers::FormHelper
|
5
|
+
include Cell::Haml
|
5
6
|
|
6
7
|
def with_form_tag_and_content_tag
|
7
8
|
render
|
@@ -35,8 +36,15 @@ class SongCell < Cell::ViewModel
|
|
35
36
|
render
|
36
37
|
end
|
37
38
|
|
38
|
-
|
39
|
+
private
|
39
40
|
def cap
|
40
41
|
"yay, #{with_output_buffer { yield } }"
|
41
42
|
end
|
43
|
+
|
44
|
+
def current_page
|
45
|
+
capture do # FIXME: this escapes!
|
46
|
+
#[link_to("1", "/1"), link_to("2", "/2")].join("+") # this breaks, too!
|
47
|
+
"<b>No current page!<b>".html_safe
|
48
|
+
end
|
49
|
+
end
|
42
50
|
end
|
data/test/haml_test.rb
CHANGED
@@ -27,6 +27,9 @@ class HamlTest < MiniTest::Spec
|
|
27
27
|
form_tag = "<form action=\"/erubis/is/horribly/outdated\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" />"
|
28
28
|
form_tag = "<form accept-charset=\"UTF-8\" action=\"/erubis/is/horribly/outdated\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /></div>" if ActionPack::VERSION::MAJOR == 3
|
29
29
|
|
30
|
+
form_with_body_tag = "<form url=\"/rails/escapes/too/much\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /><input type=\"button\"/></form>"
|
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=\"✓\" /></div><input type=\"button\"/></form>" if ActionPack::VERSION::MAJOR == 3
|
32
|
+
|
30
33
|
song_cell.(:with_form_tag_and_content_tag).must_equal %{Word.
|
31
34
|
#{form_tag}
|
32
35
|
<a href=\"/rails/sucks\">hallo
|
@@ -36,7 +39,13 @@ class HamlTest < MiniTest::Spec
|
|
36
39
|
</form>
|
37
40
|
Weiter!
|
38
41
|
Bonjour!
|
42
|
+
<a href=\"/coffee\">Coffee?</a>
|
43
|
+
<b>Yes please!</b>
|
44
|
+
<script>oui!</script>
|
45
|
+
<a href=\"/1\">1</a>+<a href=\"/2\">2</a>
|
46
|
+
<b>No current page!<b>
|
47
|
+
#{form_with_body_tag}
|
39
48
|
}
|
40
|
-
end
|
49
|
+
end
|
41
50
|
|
42
51
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cells-haml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
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-
|
12
|
+
date: 2015-05-26 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.
|
20
|
+
version: 4.0.0.beta3
|
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.
|
27
|
+
version: 4.0.0.beta3
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: haml
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,13 +77,16 @@ extra_rdoc_files: []
|
|
77
77
|
files:
|
78
78
|
- ".gitignore"
|
79
79
|
- ".travis.yml"
|
80
|
+
- CHANGES.md
|
80
81
|
- Gemfile
|
81
82
|
- LICENSE.txt
|
82
83
|
- README.md
|
83
84
|
- Rakefile
|
84
85
|
- cells-haml.gemspec
|
85
86
|
- gemfiles/rails_3.2-tilt-1.4.gemfile
|
87
|
+
- gemfiles/rails_4.0-tilt-1.4.gemfile
|
86
88
|
- gemfiles/rails_4.2-tilt-1.4.gemfile
|
89
|
+
- gemfiles/rails_4.2-tilt-2.0-rails-haml-0.9.gemfile
|
87
90
|
- gemfiles/rails_4.2-tilt-2.0.gemfile
|
88
91
|
- gemfiles/rails_4.2-tilt-3.0.gemfile
|
89
92
|
- lib/cell/haml.rb
|