html2slim 0.1.1 → 0.2.0
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 +5 -3
- data/lib/html2slim/command.rb +2 -0
- data/lib/html2slim/converter.rb +4 -4
- data/lib/html2slim/hpricot_monkeypatches.rb +4 -2
- data/lib/html2slim/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: 44b797bc3773fce1d804c911e1d37cbbdda05f42
|
4
|
+
data.tar.gz: 56ac9b993d994e044c0066312b2c7c97e7d5d0dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f73e26146faa023907be525d087665302d0108f06b28c9aac79f925d893e13dd700312c1c306f40c4d526efc6c89ab5dbfeee58e45a7acd189f4dd0db8bacf8
|
7
|
+
data.tar.gz: 68dec2af87d41e5a7cd11fde3cbef56ba2de2edafe05dcb2321e2cd9a7f9908ade5657367b081aebd0deae2677df600919c0379fba8c5568a965dfd3f69ddab3
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+

|
2
|
+
|
1
3
|
[](https://travis-ci.org/slim-template/html2slim)
|
2
4
|
|
3
5
|
[](https://codeclimate.com/github/slim-template/html2slim)
|
@@ -38,14 +40,14 @@ This project is released under the MIT license.
|
|
38
40
|
|
39
41
|
## Author
|
40
42
|
|
41
|
-
[Maiz Lulkin] (https://github.com/joaomilho)
|
43
|
+
[Maiz Lulkin] (https://github.com/joaomilho) and [contributors](https://github.com/slim-template/html2slim/graphs/contributors)
|
42
44
|
|
43
45
|
## OFFICIAL REPO
|
44
46
|
|
45
|
-
https://github.com/slim-template/html2slim
|
47
|
+
[https://github.com/slim-template/html2slim](https://github.com/slim-template/html2slim)
|
46
48
|
|
47
49
|
## ROADMAP
|
48
50
|
|
49
|
-
1. ERB support is
|
51
|
+
1. ERB support is beta, and works only for ~92.6% of the cases. Lotsa weird regexes. Gotta improve that.
|
50
52
|
2. Use temple.
|
51
53
|
3. Merge with other *2slim gems. Would be handy.
|
data/lib/html2slim/command.rb
CHANGED
data/lib/html2slim/converter.rb
CHANGED
@@ -18,14 +18,14 @@ module HTML2Slim
|
|
18
18
|
|
19
19
|
erb.gsub!(/<%(.+?)\s*\{\s*(\|.+?\|)?\s*%>/){ %(<%#{$1} do #{$2}%>) }
|
20
20
|
|
21
|
-
#
|
22
|
-
erb.gsub!(/<%(-\s+)?(\s*
|
21
|
+
# case, if, for, unless, until, while, and blocks...
|
22
|
+
erb.gsub!(/<%(-\s+)?((\s*(case|if|for|unless|until|while) .+?)|.+?do\s*(\|.+?\|)?\s*)-?%>/){ %(<ruby code="#{$2.gsub(/"/, '"')}">) }
|
23
23
|
# else
|
24
24
|
erb.gsub!(/<%-?\s*else\s*-?%>/, %(</ruby><ruby code="else">))
|
25
25
|
# elsif
|
26
|
-
erb.gsub!(/<%-?\s*(elsif .+?)\s*-?%>/){ %(</ruby><ruby code="#{$1}">) }
|
26
|
+
erb.gsub!(/<%-?\s*(elsif .+?)\s*-?%>/){ %(</ruby><ruby code="#{$1.gsub(/"/, '"')}">) }
|
27
27
|
# when
|
28
|
-
erb.gsub!(/<%-?\s*(when .+?)\s*-?%>/){ %(</ruby><ruby code="#{$1}">) }
|
28
|
+
erb.gsub!(/<%-?\s*(when .+?)\s*-?%>/){ %(</ruby><ruby code="#{$1.gsub(/"/, '"')}">) }
|
29
29
|
erb.gsub!(/<%\s*(end|}|end\s+-)\s*%>/, %(</ruby>))
|
30
30
|
erb.gsub!(/<%(.+?)\s*-?%>/m){ %(<ruby code="#{$1.gsub(/"/, '"')}"></ruby>) }
|
31
31
|
@slim ||= Hpricot(erb).to_slim
|
@@ -44,6 +44,8 @@ class Hpricot::DocType
|
|
44
44
|
end
|
45
45
|
|
46
46
|
class Hpricot::Elem
|
47
|
+
BLANK_RE = /\A[[:space:]]*\z/
|
48
|
+
|
47
49
|
def slim(lvl=0)
|
48
50
|
r = ' ' * lvl
|
49
51
|
|
@@ -97,11 +99,11 @@ class Hpricot::Elem
|
|
97
99
|
end
|
98
100
|
|
99
101
|
def has_id?
|
100
|
-
has_attribute?('id')
|
102
|
+
has_attribute?('id') && !(BLANK_RE === self['id'])
|
101
103
|
end
|
102
104
|
|
103
105
|
def has_class?
|
104
|
-
has_attribute?('class')
|
106
|
+
has_attribute?('class') && !(BLANK_RE === self['class'])
|
105
107
|
end
|
106
108
|
|
107
109
|
def ruby?
|
data/lib/html2slim/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html2slim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maiz Lulkin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hpricot
|