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 +4 -4
- data/CHANGES.md +4 -0
- data/lib/cell/slim.rb +3 -43
- data/lib/cell/slim/rails.rb +54 -0
- data/lib/cell/slim/version.rb +1 -1
- data/test/dummy/app/cells/song/with_form_tag_and_content_tag.slim +4 -1
- data/test/slim_test.rb +9 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 58aff2d0b7ba266f4645a63b528f6a120bb07efc
|
|
4
|
+
data.tar.gz: f9a43e882d97fe7189233aea4ca47315ea1e48de
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: db12f7e2ecf8decf77fba4b51ef5824fb39eadb0e8db27e3b2d6a8c5931c1b31f6f1c7d9d8d711b1f808a2e1050fadb5fc1aade66af66937da8d09ea22e523df
|
|
7
|
+
data.tar.gz: 311c907fd62798773b154b1626beee6b5f729e5f26e3d0cf26beb0fb4b4603527aa6837916e247ff283cfbae5b77d853fbe08d48c571dd4d1fe8bd00e0bc8368
|
data/CHANGES.md
CHANGED
data/lib/cell/slim.rb
CHANGED
|
@@ -21,49 +21,9 @@ module Cell
|
|
|
21
21
|
}
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
data/lib/cell/slim/version.rb
CHANGED
data/test/slim_test.rb
CHANGED
|
@@ -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\">
|
|
34
|
+
<a href=\"/rails/sucks\">
|
|
35
|
+
hallo
|
|
36
|
+
<div class="row">Cool</div>
|
|
35
37
|
</a>
|
|
36
38
|
<ul data-x="{"a":"1"}">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.
|
|
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-
|
|
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.
|
|
127
|
+
rubygems_version: 2.4.8
|
|
127
128
|
signing_key:
|
|
128
129
|
specification_version: 4
|
|
129
130
|
summary: Slim integration for Cells.
|