cells-hamlit 0.1.0 → 0.1.1

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: 1bad7fda55152c7469773eb40abfccedc6fe390f
4
- data.tar.gz: 0312993ff12918aa59175a42e743be2aad170b0b
3
+ metadata.gz: c5bca0aa064512de1aa99c886d0f11de003524ee
4
+ data.tar.gz: f5652a70cbd2244b03bfc73e73b729497cb1dbc6
5
5
  SHA512:
6
- metadata.gz: 5fe604051170e9a8c3d260cc5ffdf49e7af46faf1065ebed146615586858cc7b063fae9c8983b89578bb34508b784ae45d9207347283dc4789a85d68009b8ad0
7
- data.tar.gz: 3b51386a039c184a06a93beaa1b7ca770852ed593d05a8d961e325eb5a6c988c1d1139419e04d26366708840c2252dfc6f244d3d6dd72d369ab13631398dbdd2
6
+ metadata.gz: ad97b666ffb94b5d30c95fe2f43d1f129b567dd8e5834552c1db32623735396bbc4baebd0435e12d4faee0f37439087fff5c87a454b6bb7b8d74c9c4a8fee4cd
7
+ data.tar.gz: b7486f57539cc1685cfdebc3e42c37ffef60a941dfc0a8d38aa12b0cfd6a258d05b76a94c2d2255c1f14eda0c2f9638f8b0303b9c87ff73ccd361d91d8b1b0e5
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.1.1
2
+
3
+ * Now using `hamlit-block` for capturing.
4
+
1
5
  # 0.1.0
2
6
 
3
7
  Start based on cells-haml
@@ -18,4 +22,4 @@ Require >= haml-5.0.0.beta2.
18
22
 
19
23
  # 0.0.4
20
24
 
21
- * Added `capture` helper to override Rails escaping.
25
+ * Added `capture` helper to override Rails escaping.
data/Gemfile CHANGED
@@ -7,4 +7,5 @@ gem 'cells', path: "../cells"#github: 'apotonick/cells'
7
7
  gem 'railties'
8
8
  gem 'actionpack'
9
9
  gem 'actionview'
10
- gem "haml", github:"haml/haml" #"4.1.0.beta1" #github: "haml/haml" # we need 4.1.
10
+
11
+ gem "minitest-line"
data/README.md CHANGED
@@ -2,9 +2,6 @@
2
2
 
3
3
  Hamlit support for Cells. [Hamlit](https://github.com/k0kubun/hamlit) is a faster implementation of Haml.
4
4
 
5
- ## Beta
6
-
7
- This gem is not safe for work at the moment!
8
5
 
9
6
  ## Installation
10
7
 
@@ -13,8 +10,20 @@ Add this line to your application's Gemfile:
13
10
  ```ruby
14
11
  gem "cells-hamlit"
15
12
  gem "hamlit"
13
+ gem "hamlit-block"
14
+ ```
15
+
16
+ Note that you need [hamlit-block](https://github.com/k0kubun/hamlit-block), too, for `capture` support. This will slightly change semantics with blocks, as follows. # TODO
17
+
18
+ ## Capture
19
+
20
+ ```haml
21
+ - content = capture do
22
+ = "takashi is king!"
16
23
  ```
17
24
 
25
+ To capture strings, the `=` directive is needed in the block.
26
+
18
27
  ## HTML Escaping
19
28
 
20
29
  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.
data/cells-hamlit.gemspec CHANGED
@@ -1,24 +1,25 @@
1
- lib = File.expand_path('../lib/', __FILE__)
1
+ lib = File.expand_path("../lib/", __FILE__)
2
2
  $:.unshift lib unless $:.include?(lib)
3
3
 
4
- require 'cell/hamlit/version'
4
+ require "cell/hamlit/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = 'cells-hamlit'
7
+ spec.name = "cells-hamlit"
8
8
  spec.version = Cell::Hamlit::VERSION
9
- spec.authors = ['Abdelkader Boudih', 'Nick Sutterer', 'Timo Schilling']
10
- spec.email = %w(terminale@gmail.com apotonick@gmail.com timo@schilling.io)
11
- spec.summary = 'Hamlit integration for Cells'
9
+ spec.authors = ["Nick Sutterer", "Timo Schilling"]
10
+ spec.email = %w(apotonick@gmail.com timo@schilling.io)
11
+ spec.summary = "Hamlit integration for Cells"
12
12
  spec.description = spec.summary
13
- spec.homepage = 'https://github.com/trailblazer/cells-hamlit'
14
- spec.license = 'MIT'
13
+ spec.homepage = "https://github.com/trailblazer/cells-hamlit"
14
+ spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
17
17
  spec.test_files = spec.files.grep(%r{^(test)/})
18
- spec.require_paths = ['lib']
18
+ spec.require_paths = ["lib"]
19
19
 
20
- spec.add_dependency 'cells', '~> 4.0.0'
21
- spec.add_dependency 'hamlit'
22
- spec.add_development_dependency 'bundler'
23
- spec.add_development_dependency 'rake'
20
+ spec.add_dependency "cells", "~> 4.0"
21
+ spec.add_dependency "hamlit"
22
+ spec.add_dependency "hamlit-block", "~> 0.3.0"
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "rake"
24
25
  end
@@ -1,5 +1,5 @@
1
1
  module Cell
2
2
  module Hamlit
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
data/lib/cell/hamlit.rb CHANGED
@@ -1,18 +1,17 @@
1
- require 'hamlit'
1
+ require "hamlit"
2
+ require "hamlit/block"
2
3
 
3
4
  module Cell
4
5
  module Hamlit
5
6
  def template_options_for(options)
6
7
  {
7
- template_class: ::Hamlit::Template,
8
8
  escape_html: false,
9
+ template_class: ::Hamlit::Template,
9
10
  suffix: "haml"
10
11
  }
11
12
  end
12
13
 
13
- attr_writer :output_buffer
14
-
15
- include ActionView::Helpers::FormHelper
14
+ # include ActionView::Helpers::FormHelper
16
15
 
17
16
  # From FormTagHelper. why do they escape every possible string? why?
18
17
  def form_tag_in_block(html_options, &block)
@@ -24,6 +23,16 @@ module Cell
24
23
  "#{form_tag_html(html_options)}" << content.to_s << "</form>"
25
24
  end
26
25
 
26
+ # with fine Hamlit, we don't need magical output buffers since yielding a block returns the
27
+ # content.
28
+ def with_output_buffer(block_buffer=ViewModel::OutputBuffer.new)
29
+ yield
30
+ end
31
+
32
+ def capture(*args)
33
+ yield(*args)
34
+ end
35
+
27
36
  # def form_tag_html(html_options)
28
37
  # extra_tags = extra_tags_for_form(html_options)
29
38
  # "#{tag(:form, html_options, true) + extra_tags}"
@@ -33,8 +42,8 @@ module Cell
33
42
  # form_for_without_haml(*args, &block)
34
43
  # end
35
44
 
36
- # def content_tag(name, content_or_options_with_block=nil, options=nil, escape=false, &block)
37
- # super
38
- # end
45
+ def content_tag(name, content_or_options_with_block=nil, options=nil, escape=false, &block)
46
+ super
47
+ end
39
48
  end
40
- end
49
+ end
@@ -0,0 +1,11 @@
1
+ Hallo
2
+
3
+ - bla = 1
4
+
5
+ - hidden = capture do
6
+ Hidden!
7
+
8
+ %p
9
+ More
10
+
11
+ = hidden
@@ -25,7 +25,7 @@ Weiter!
25
25
  = content
26
26
 
27
27
  - breadcrumbs = capture do
28
- - [link_to("1", "/1"), link_to("2", "/2")].join("+")
28
+ = [link_to("1", "/1"), link_to("2", "/2")].join("+")
29
29
 
30
30
  = breadcrumbs
31
31
 
@@ -34,4 +34,4 @@ Weiter!
34
34
 
35
35
 
36
36
  = form_for OpenStruct.new, url: "/", as: "open" do |f|
37
- = f.text_field :id
37
+ = f.text_field :id
@@ -44,6 +44,10 @@ class SongCell < Cell::ViewModel
44
44
  render
45
45
  end
46
46
 
47
+ def with_capture
48
+ render
49
+ end
50
+
47
51
  private
48
52
  def cap
49
53
  "yay, #{with_output_buffer { yield } }"
@@ -55,4 +59,4 @@ private
55
59
  "<b>No current page!<b>".html_safe
56
60
  end
57
61
  end
58
- end
62
+ end
data/test/hamlit_test.rb CHANGED
@@ -16,9 +16,7 @@ class HamlitTest < MiniTest::Spec
16
16
  # content_tag { content_tag { } }
17
17
  it do song_cell.(:with_content_tag_and_content_tag).must_equal %{<span>Title:
18
18
  <div>Still Knee Deep
19
- </div>
20
- </span>
21
- }
19
+ </div></span>}
22
20
  end
23
21
 
24
22
  # form_tag { content_tag { } }
@@ -35,16 +33,16 @@ class HamlitTest < MiniTest::Spec
35
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;\" /><input type=\"text\" name=\"open[id]\" id=\"open_id\" />"
36
34
  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><input id=\"open_id\" name=\"open[id]\" size=\"30\" type=\"text\" />" if ActionPack::VERSION::MAJOR == 3
37
35
 
38
- song_cell.(:with_form_tag_and_content_tag).must_equal %{Word.
36
+ song_cell.(:with_form_tag_and_content_tag).gsub("\n", "").must_equal %{Word.
39
37
  #{form_tag}
40
- #{input_tag}
41
- <a href=\"/rails/sucks\">hallo
42
- <div class='row'>
43
- Cool
44
- </div>
45
- </a>
46
- <ul>Hallo
47
- </ul>
38
+ #{input_tag}
39
+ <a href=\"/rails/sucks\">hallo
40
+ <div class='row'>
41
+ Cool
42
+ </div>
43
+ </a>
44
+ <ul>Hallo
45
+ </ul>
48
46
  </form>
49
47
  Weiter!
50
48
  Bonjour!
@@ -56,7 +54,18 @@ Bonjour!
56
54
  #{form_with_body_tag}
57
55
  #{form_for_tag}
58
56
  </form>
59
- }
57
+ }.gsub("\n", "")
60
58
  end
61
59
 
60
+ describe "block capture" do
61
+ it do
62
+ song_cell.(:with_capture).must_equal %{Hallo
63
+ <p>
64
+ More
65
+ </p>
66
+ Hidden!
67
+
68
+ }
69
+ end
70
+ end
62
71
  end
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cells-hamlit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
- - Abdelkader Boudih
8
7
  - Nick Sutterer
9
8
  - Timo Schilling
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2015-10-21 00:00:00.000000000 Z
12
+ date: 2016-01-21 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: cells
@@ -18,14 +17,14 @@ dependencies:
18
17
  requirements:
19
18
  - - "~>"
20
19
  - !ruby/object:Gem::Version
21
- version: 4.0.0
20
+ version: '4.0'
22
21
  type: :runtime
23
22
  prerelease: false
24
23
  version_requirements: !ruby/object:Gem::Requirement
25
24
  requirements:
26
25
  - - "~>"
27
26
  - !ruby/object:Gem::Version
28
- version: 4.0.0
27
+ version: '4.0'
29
28
  - !ruby/object:Gem::Dependency
30
29
  name: hamlit
31
30
  requirement: !ruby/object:Gem::Requirement
@@ -40,6 +39,20 @@ dependencies:
40
39
  - - ">="
41
40
  - !ruby/object:Gem::Version
42
41
  version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: hamlit-block
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: 0.3.0
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: 0.3.0
43
56
  - !ruby/object:Gem::Dependency
44
57
  name: bundler
45
58
  requirement: !ruby/object:Gem::Requirement
@@ -70,7 +83,6 @@ dependencies:
70
83
  version: '0'
71
84
  description: Hamlit integration for Cells
72
85
  email:
73
- - terminale@gmail.com
74
86
  - apotonick@gmail.com
75
87
  - timo@schilling.io
76
88
  executables: []
@@ -97,6 +109,7 @@ files:
97
109
  - test/dummy/Rakefile
98
110
  - test/dummy/app/cells/song/render_in_render.haml
99
111
  - test/dummy/app/cells/song/render_in_render_2.haml
112
+ - test/dummy/app/cells/song/with_capture.haml
100
113
  - test/dummy/app/cells/song/with_content_tag.haml
101
114
  - test/dummy/app/cells/song/with_content_tag_and_content_tag.haml
102
115
  - test/dummy/app/cells/song/with_form_tag_and_content_tag.haml
@@ -110,7 +123,6 @@ files:
110
123
  - test/dummy/config/initializers/cells.rb
111
124
  - test/dummy/config/locales/en.yml
112
125
  - test/dummy/config/routes.rb
113
- - test/dummy/log/test.log
114
126
  - test/hamlit_test.rb
115
127
  - test/test_helper.rb
116
128
  homepage: https://github.com/trailblazer/cells-hamlit
@@ -142,6 +154,7 @@ test_files:
142
154
  - test/dummy/Rakefile
143
155
  - test/dummy/app/cells/song/render_in_render.haml
144
156
  - test/dummy/app/cells/song/render_in_render_2.haml
157
+ - test/dummy/app/cells/song/with_capture.haml
145
158
  - test/dummy/app/cells/song/with_content_tag.haml
146
159
  - test/dummy/app/cells/song/with_content_tag_and_content_tag.haml
147
160
  - test/dummy/app/cells/song/with_form_tag_and_content_tag.haml
@@ -155,7 +168,5 @@ test_files:
155
168
  - test/dummy/config/initializers/cells.rb
156
169
  - test/dummy/config/locales/en.yml
157
170
  - test/dummy/config/routes.rb
158
- - test/dummy/log/test.log
159
171
  - test/hamlit_test.rb
160
172
  - test/test_helper.rb
161
- has_rdoc:
@@ -1,96 +0,0 @@
1
- -------------------------------------------------------------------------------------
2
- CellGeneratorTest: test_create_cell_that_inherits_from_custom_cell_class_if_specified
3
- -------------------------------------------------------------------------------------
4
- -----------------------------------------------------
5
- CellGeneratorTest: test_work_with_namespaces_and_haml
6
- -----------------------------------------------------
7
- --------------------------------------------
8
- CellGeneratorTest: test_work_with_namespaces
9
- --------------------------------------------
10
- --------------------------------------------------
11
- CellGeneratorTest: test_create_the_standard_assets
12
- --------------------------------------------------
13
- --------------------------------------------
14
- CellGeneratorTest: test_work_with_namespaces
15
- --------------------------------------------
16
- --------------------------------------------------
17
- CellGeneratorTest: test_create_the_standard_assets
18
- --------------------------------------------------
19
- -------------------------------------------------------------------------------------
20
- CellGeneratorTest: test_create_cell_that_inherits_from_custom_cell_class_if_specified
21
- -------------------------------------------------------------------------------------
22
- -----------------------------------------------------
23
- CellGeneratorTest: test_work_with_namespaces_and_haml
24
- -----------------------------------------------------
25
- -------------------------------------------------------------------------------------
26
- CellGeneratorTest: test_create_cell_that_inherits_from_custom_cell_class_if_specified
27
- -------------------------------------------------------------------------------------
28
- --------------------------------------------
29
- CellGeneratorTest: test_work_with_namespaces
30
- --------------------------------------------
31
- --------------------------------------------------
32
- CellGeneratorTest: test_create_the_standard_assets
33
- --------------------------------------------------
34
- -----------------------------------------------------
35
- CellGeneratorTest: test_work_with_namespaces_and_haml
36
- -----------------------------------------------------
37
- --------------------------------------------
38
- CellGeneratorTest: test_work_with_namespaces
39
- --------------------------------------------
40
- --------------------------------------------------
41
- CellGeneratorTest: test_create_the_standard_assets
42
- --------------------------------------------------
43
- -----------------------------------------------------
44
- CellGeneratorTest: test_work_with_namespaces_and_haml
45
- -----------------------------------------------------
46
- -------------------------------------------------------------------------------------
47
- CellGeneratorTest: test_create_cell_that_inherits_from_custom_cell_class_if_specified
48
- -------------------------------------------------------------------------------------
49
- -----------------------------------------------------
50
- CellGeneratorTest: test_work_with_namespaces_and_haml
51
- -----------------------------------------------------
52
- --------------------------------------------------
53
- CellGeneratorTest: test_create_the_standard_assets
54
- --------------------------------------------------
55
- --------------------------------------------
56
- CellGeneratorTest: test_work_with_namespaces
57
- --------------------------------------------
58
- -------------------------------------------------------------------------------------
59
- CellGeneratorTest: test_create_cell_that_inherits_from_custom_cell_class_if_specified
60
- -------------------------------------------------------------------------------------
61
- -------------------------------------------------------------------------------------
62
- CellGeneratorTest: test_create_cell_that_inherits_from_custom_cell_class_if_specified
63
- -------------------------------------------------------------------------------------
64
- --------------------------------------------------
65
- CellGeneratorTest: test_create_the_standard_assets
66
- --------------------------------------------------
67
- --------------------------------------------
68
- CellGeneratorTest: test_work_with_namespaces
69
- --------------------------------------------
70
- -----------------------------------------------------
71
- CellGeneratorTest: test_work_with_namespaces_and_haml
72
- -----------------------------------------------------
73
- -------------------------------------------------------------------------------------
74
- CellGeneratorTest: test_create_cell_that_inherits_from_custom_cell_class_if_specified
75
- -------------------------------------------------------------------------------------
76
- --------------------------------------------
77
- CellGeneratorTest: test_work_with_namespaces
78
- --------------------------------------------
79
- --------------------------------------------------
80
- CellGeneratorTest: test_create_the_standard_assets
81
- --------------------------------------------------
82
- -----------------------------------------------------
83
- CellGeneratorTest: test_work_with_namespaces_and_haml
84
- -----------------------------------------------------
85
- --------------------------------------------------
86
- CellGeneratorTest: test_create_the_standard_assets
87
- --------------------------------------------------
88
- --------------------------------------------
89
- CellGeneratorTest: test_work_with_namespaces
90
- --------------------------------------------
91
- -------------------------------------------------------------------------------------
92
- CellGeneratorTest: test_create_cell_that_inherits_from_custom_cell_class_if_specified
93
- -------------------------------------------------------------------------------------
94
- -----------------------------------------------------
95
- CellGeneratorTest: test_work_with_namespaces_and_haml
96
- -----------------------------------------------------