cells-slim 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a53be884b2a5686c65df3b073d2010c380f255e
4
- data.tar.gz: 9476c9c296cf27f24e2d01fb0776f760b8098db8
3
+ metadata.gz: 58aff2d0b7ba266f4645a63b528f6a120bb07efc
4
+ data.tar.gz: f9a43e882d97fe7189233aea4ca47315ea1e48de
5
5
  SHA512:
6
- metadata.gz: 8751297e177abc681d5adeb06f5916ba8fe77f2d4db3038d768d940168f9807aaa5e677a8ea1379988113e8b1c266d609e3fce2fbc974a9eaf67afd416c4c18c
7
- data.tar.gz: 6f41d30423fd9157f1e430029a6488c59d95d813ae3fd1e10713508bda339c61808c1e3abc586deca576b73d9b3d05744878d6a49c2fd200792fd0d325d1f210
6
+ metadata.gz: db12f7e2ecf8decf77fba4b51ef5824fb39eadb0e8db27e3b2d6a8c5931c1b31f6f1c7d9d8d711b1f808a2e1050fadb5fc1aade66af66937da8d09ea22e523df
7
+ data.tar.gz: 311c907fd62798773b154b1626beee6b5f729e5f26e3d0cf26beb0fb4b4603527aa6837916e247ff283cfbae5b77d853fbe08d48c571dd4d1fe8bd00e0bc8368
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.0.4
2
+
3
+ * Make Rails optional. This allows using cells-slim in other frameworks like [Sinatra](https://github.com/apotonick/gemgem-sinatra).
4
+
1
5
  0.0.3
2
6
 
3
7
  * Fix #concat.
@@ -21,49 +21,9 @@ module Cell
21
21
  }
22
22
  end
23
23
 
24
- include ActionView::Helpers::FormHelper
25
-
26
- def with_output_buffer(block_buffer=ViewModel::OutputBuffer.new)
27
- @output_buffer, old_buffer = block_buffer, @output_buffer
28
- yield
29
- @output_buffer = old_buffer
30
-
31
- block_buffer
32
- end
33
-
34
- def capture(*args)
35
- value = nil
36
- buffer = with_output_buffer { value = yield(*args) }
37
-
38
- return buffer.to_s if buffer.size > 0
39
- value # this applies for "Beachparty" string-only statements.
40
- end
41
-
42
- # From FormTagHelper. why do they escape every possible string? why?
43
- def form_tag_in_block(html_options, &block)
44
- content = capture(&block)
45
- form_tag_with_body(html_options, content)
46
- end
47
-
48
- def form_tag_with_body(html_options, content)
49
- "#{form_tag_html(html_options)}" << content.to_s << "</form>"
50
- end
51
-
52
- def form_tag_html(html_options)
53
- extra_tags = extra_tags_for_form(html_options)
54
- "#{tag(:form, html_options, true) + extra_tags}"
55
- end
56
-
57
- def tag_options(options, escape = true)
58
- super(options, true)
59
- end
60
-
61
- def content_tag_string(name, content, options, escape=true)
62
- super(name, content, options, false)
63
- end
64
-
65
- def concat(string)
66
- @output_buffer << string
24
+ if Object.const_defined?(:ActionView)
25
+ require "cell/slim/rails"
26
+ include Cell::Slim::Rails
67
27
  end
68
28
  end
69
29
  end
@@ -0,0 +1,54 @@
1
+ module Cell
2
+ module Slim::Rails
3
+ def self.included(includer)
4
+ includer.send :include, ActionView::Helpers::FormHelper
5
+ includer.send :include, ::Cell::Slim::Rails::Helpers
6
+ end
7
+
8
+ module Helpers # include after AV helpers to override.
9
+ def with_output_buffer(block_buffer=ViewModel::OutputBuffer.new)
10
+ @output_buffer, old_buffer = block_buffer, @output_buffer
11
+ yield
12
+ @output_buffer = old_buffer
13
+
14
+ block_buffer
15
+ end
16
+
17
+ def capture(*args)
18
+ value = nil
19
+ buffer = with_output_buffer { value = yield(*args) }
20
+
21
+ return buffer.to_s if buffer.size > 0
22
+ value # this applies for "Beachparty" string-only statements.
23
+ end
24
+
25
+ # From FormTagHelper. why do they escape every possible string? why?
26
+ def form_tag_in_block(html_options, &block)
27
+ content = capture(&block)
28
+ form_tag_with_body(html_options, content)
29
+ end
30
+
31
+ def form_tag_with_body(html_options, content)
32
+ "#{form_tag_html(html_options)}" << content.to_s << "</form>"
33
+ end
34
+
35
+ def form_tag_html(html_options)
36
+ extra_tags = extra_tags_for_form(html_options)
37
+ "#{tag(:form, html_options, true) + extra_tags}"
38
+ end
39
+
40
+ def tag_options(options, escape = true)
41
+ super(options, true)
42
+ end
43
+
44
+ def content_tag_string(name, content, options, escape=true)
45
+ super(name, content, options, false)
46
+ end
47
+
48
+ def concat(string)
49
+ @output_buffer << string
50
+ self
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,5 +1,5 @@
1
1
  module Cell
2
2
  module Slim
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -2,8 +2,11 @@
2
2
 
3
3
  = form_tag "/erubis/is/horribly/outdated"
4
4
  = text_field_tag :id
5
- = link_to "/rails/sucks"
5
+ = link_to "/rails/sucks" do
6
6
  | hallo
7
+ .row
8
+ | Cool
9
+
7
10
 
8
11
  = content_tag(:ul, "data-x" => '{"a":"1"}')
9
12
  | Hallo
@@ -31,7 +31,9 @@ class SlimTest < MiniTest::Spec
31
31
  song_cell.(:with_form_tag_and_content_tag).must_equal %{Word.
32
32
  #{form_tag}
33
33
  #{input_tag}
34
- <a href=\"/rails/sucks\">hallo
34
+ <a href=\"/rails/sucks\">
35
+ hallo
36
+ <div class="row">Cool</div>
35
37
  </a>
36
38
  <ul data-x="{&quot;a&quot;:&quot;1&quot;}">Hallo
37
39
  </ul>
@@ -50,4 +52,10 @@ Bonjour!
50
52
  }.gsub("\n", "").gsub(" ", "")
51
53
  end
52
54
 
55
+ it 'allows concatenation chains' do
56
+ song_cell.capture do
57
+ song_cell.concat('Lorem').concat('ipsum')
58
+ end
59
+ end
60
+
53
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cells-slim
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-06-23 00:00:00.000000000 Z
12
+ date: 2015-12-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cells
@@ -85,6 +85,7 @@ files:
85
85
  - cells-slim.gemspec
86
86
  - gemfiles/rails4.2.gemfile
87
87
  - lib/cell/slim.rb
88
+ - lib/cell/slim/rails.rb
88
89
  - lib/cell/slim/version.rb
89
90
  - lib/cells-slim.rb
90
91
  - test/dummy/Rakefile
@@ -123,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
124
  version: '0'
124
125
  requirements: []
125
126
  rubyforge_project:
126
- rubygems_version: 2.2.2
127
+ rubygems_version: 2.4.8
127
128
  signing_key:
128
129
  specification_version: 4
129
130
  summary: Slim integration for Cells.