rbem 0.1.5 → 0.2
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/README.md +24 -0
- data/lib/rbem.rb +55 -20
- data/lib/rbem/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 720d03b5417352538a07c97a1e5fce646a17b671
|
4
|
+
data.tar.gz: 3893b7c30e91d4da744877698f9cc06ef18c0f8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df9d32c6d3cffdfb53d92fe302314f1be1346f5cdf56215b45ecdd6ca5fde912a0813a66946e02b658ae6ad4249b2356f23a12554d061d656d7e3fd320dc5c23
|
7
|
+
data.tar.gz: e049adf1955637122b9b89fd51075c300ff039968288e7b9fbf90f78a74043bccf9f39a35b9910df4c691ec1f0c091a95b501d9bae85fddcce0c68b71036961c
|
data/README.md
CHANGED
@@ -60,6 +60,18 @@ end
|
|
60
60
|
/ </div>
|
61
61
|
```
|
62
62
|
|
63
|
+
Multiple modifiers:
|
64
|
+
|
65
|
+
```slim
|
66
|
+
= b 'block', 'full hot'
|
67
|
+
= e 'element', 'active fix'
|
68
|
+
|
69
|
+
/ == Returns:
|
70
|
+
/ <span class="block block_full block_hot">
|
71
|
+
/ <a class="block__element block__element_active block__element_fix"></a>
|
72
|
+
/ </span>
|
73
|
+
```
|
74
|
+
|
63
75
|
Set block/element type(`Symbol`):
|
64
76
|
|
65
77
|
```slim
|
@@ -108,6 +120,18 @@ Inherit block modifier to element `&modifier`:
|
|
108
120
|
/ </div>
|
109
121
|
```
|
110
122
|
|
123
|
+
Inherit specific block modifier to element `&modifier:block_mod`:
|
124
|
+
|
125
|
+
```slim
|
126
|
+
= b 'block', 'full hot'
|
127
|
+
= e 'element', '&active:hot'
|
128
|
+
|
129
|
+
/ == Returns:
|
130
|
+
/ <div class="block block_full block_hot">
|
131
|
+
/ <div class="block__element block__element_active block_hot__element_active"></div>
|
132
|
+
/ </div>
|
133
|
+
```
|
134
|
+
|
111
135
|
## Contributing
|
112
136
|
|
113
137
|
1. Fork it ( https://github.com/vadimskrotsky/rbem/fork )
|
data/lib/rbem.rb
CHANGED
@@ -11,12 +11,12 @@ module Rbem
|
|
11
11
|
_args = parse_args(args)
|
12
12
|
|
13
13
|
@block_name = _args[:name]
|
14
|
-
@
|
14
|
+
@block_mods = _args[:mods]
|
15
15
|
|
16
16
|
block_type = _args[:type]
|
17
17
|
block_opts = _args[:options]
|
18
18
|
|
19
|
-
block_opts[:class] = collect_bem_class(@block_name, @
|
19
|
+
block_opts[:class] = collect_bem_class(@block_name, @block_mods, block_opts, type: :block)
|
20
20
|
|
21
21
|
content_tag(block_type, block_given? ? capture(&block) : nil, block_opts)
|
22
22
|
end
|
@@ -25,17 +25,17 @@ module Rbem
|
|
25
25
|
_args = parse_args(args)
|
26
26
|
|
27
27
|
el_name = _args[:name]
|
28
|
-
|
28
|
+
el_mods = _args[:mods]
|
29
29
|
|
30
30
|
el_type = _args[:type]
|
31
31
|
el_opts = _args[:options]
|
32
32
|
|
33
33
|
el_opts[:class] = collect_bem_class(el_name,
|
34
|
-
|
34
|
+
el_mods,
|
35
35
|
el_opts,
|
36
|
-
type:
|
37
|
-
|
38
|
-
|
36
|
+
type: :element,
|
37
|
+
inherit_names: _args[:i_names],
|
38
|
+
inherit_mods: _args[:i_mods] )
|
39
39
|
|
40
40
|
content_tag(el_type, block_given? ? capture(&block) : nil, el_opts)
|
41
41
|
end
|
@@ -47,20 +47,30 @@ module Rbem
|
|
47
47
|
_type = args.select{ |e| e.is_a?(Symbol) }
|
48
48
|
_options = args.select{ |e| e.is_a?(Hash) }
|
49
49
|
_return = {}
|
50
|
+
|
50
51
|
if _name_mod[0].present?
|
51
|
-
_return[:name] = _name_mod[0].sub('&','')
|
52
|
-
|
52
|
+
_return[:name] = _name_mod[0].sub('&','').split(':')[0]
|
53
|
+
if _name_mod[0].start_with?('&')
|
54
|
+
_names = _name_mod[0].split(':')
|
55
|
+
_names.shift
|
56
|
+
if _names.empty?
|
57
|
+
_names = @block_mods
|
58
|
+
end
|
59
|
+
_return[:i_names] = _names
|
60
|
+
end
|
53
61
|
end
|
62
|
+
|
54
63
|
if _name_mod[1].present?
|
55
|
-
_return[:
|
56
|
-
_return[:
|
64
|
+
_return[:mods] = _name_mod[1].split.map { |e| e.sub('&','') }
|
65
|
+
_return[:i_mods] = _name_mod[1].split.select { |e| e.start_with?('&') }
|
57
66
|
end
|
67
|
+
|
58
68
|
_return[:type] = _type[0] || :div
|
59
69
|
_return[:options] = _options[0] || {}
|
60
70
|
_return
|
61
71
|
end
|
62
72
|
|
63
|
-
def collect_bem_class(name,
|
73
|
+
def collect_bem_class(name, mods, options, type: nil, inherit_names: nil, inherit_mods: nil)
|
64
74
|
_separ = @@notation
|
65
75
|
_separ = '_' unless _separ.is_a?(String)
|
66
76
|
|
@@ -68,21 +78,46 @@ module Rbem
|
|
68
78
|
|
69
79
|
if type === :block
|
70
80
|
_class << "#{name}"
|
71
|
-
if
|
72
|
-
|
81
|
+
if mods
|
82
|
+
for mod in mods
|
83
|
+
_class << "#{name}#{_separ}#{mod}"
|
84
|
+
end
|
73
85
|
end
|
74
86
|
end
|
75
87
|
|
76
88
|
if type === :element
|
89
|
+
|
90
|
+
# block__element
|
77
91
|
_class << "#{@block_name}__#{name}"
|
78
|
-
|
79
|
-
|
92
|
+
|
93
|
+
# block__element_mod
|
94
|
+
if mods
|
95
|
+
for mod in mods
|
96
|
+
mod = mod.split(':')[0].sub('&','')
|
97
|
+
_class << "#{@block_name}__#{name}#{_separ}#{mod}"
|
98
|
+
end
|
80
99
|
end
|
81
|
-
|
82
|
-
|
100
|
+
|
101
|
+
# block_mod__element
|
102
|
+
if inherit_names and @block_mods.present?
|
103
|
+
for inherit_name in inherit_names
|
104
|
+
_class << "#{@block_name}#{_separ}#{inherit_name}__#{name}"
|
105
|
+
end
|
83
106
|
end
|
84
|
-
|
85
|
-
|
107
|
+
|
108
|
+
# block_mod__element_mod
|
109
|
+
if inherit_mods and mods and @block_mods.present?
|
110
|
+
for i_mod in inherit_mods
|
111
|
+
el_mod = i_mod.split(':')[0].sub('&','')
|
112
|
+
block_mods = i_mod.split(':')
|
113
|
+
block_mods.shift
|
114
|
+
if block_mods.empty?
|
115
|
+
block_mods = @block_mods
|
116
|
+
end
|
117
|
+
for block_mod in block_mods
|
118
|
+
_class << "#{@block_name}#{_separ}#{block_mod}__#{name}#{_separ}#{el_mod}"
|
119
|
+
end
|
120
|
+
end
|
86
121
|
end
|
87
122
|
end
|
88
123
|
|
data/lib/rbem/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vadim Skrotsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09
|
11
|
+
date: 2014-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|