hamlizer 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/lib/hamlizer.rb +2 -2
- data/lib/hamlizer/attributes_haml_converter.rb +5 -1
- data/lib/hamlizer/version.rb +1 -1
- data/spec/lib/hamlizer_spec.rb +4 -0
- data/spec/test_files/nested_divs_with_classes.html.erb +7 -0
- data/spec/test_files/nested_divs_with_classes.html.haml +5 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ca7996fbf701443bb00171723fafac8f564a292
|
4
|
+
data.tar.gz: a5b584cc4513c41490b63c69dcdd939df8dbb661
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cc8d74eaad65f544f6531729e0ddccebdc1d7bc4bb58df2c3e2d9c4cac7b2f460c73675b73f34732e5ae71eddf4dec0915c9307089cf041d21833eb61d4ed7e
|
7
|
+
data.tar.gz: 7b7623540838b0ca4a839b84924e6fa2f07816d767fdc1b399d2c99bae87383373bae18beb4a6172e83562f3590cc62db944f8e30c10d4f808c4bc6054901dcb
|
data/lib/hamlizer.rb
CHANGED
@@ -15,9 +15,9 @@ module Hamlizer
|
|
15
15
|
self.current_level = 0
|
16
16
|
html.strip!
|
17
17
|
html.squeeze! ' '
|
18
|
-
convert_erb_to_parseable_xml!
|
18
|
+
convert_erb_to_parseable_xml! html
|
19
19
|
|
20
|
-
if html.start_with?
|
20
|
+
if html.start_with? '<html>'
|
21
21
|
root = Nokogiri::HTML.parse(html).root
|
22
22
|
else
|
23
23
|
root = Nokogiri::HTML::DocumentFragment.parse(html)
|
@@ -5,13 +5,17 @@ module Hamlizer
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def haml
|
8
|
-
element.has_attributes? ? (id_haml + class_haml + regular_attributes_haml) : ''
|
8
|
+
element.has_attributes? ? level_spacing + (id_haml + class_haml + regular_attributes_haml) : ''
|
9
9
|
end
|
10
10
|
|
11
11
|
private
|
12
12
|
|
13
13
|
attr_reader :element
|
14
14
|
|
15
|
+
def level_spacing
|
16
|
+
element.div? ? (' ' * Hamlizer.current_level) : ''
|
17
|
+
end
|
18
|
+
|
15
19
|
def attribute_haml(name, value)
|
16
20
|
if name.match(/^\w+$/)
|
17
21
|
attribute_name = "#{name}:"
|
data/lib/hamlizer/version.rb
CHANGED
data/spec/lib/hamlizer_spec.rb
CHANGED
@@ -60,6 +60,10 @@ module Hamlizer
|
|
60
60
|
expect(hamlize('<div>abc<p>hello<span>abc</span></p></div>')).to eq "%div\n abc\n %p\n hello\n %span abc"
|
61
61
|
end
|
62
62
|
|
63
|
+
it 'converts nested divs with classes' do
|
64
|
+
expect(hamlize(content_from('nested_divs_with_classes.html.erb'))).to eq content_from('nested_divs_with_classes.html.haml')
|
65
|
+
end
|
66
|
+
|
63
67
|
it 'converts a tag with attributes' do
|
64
68
|
title = 'El Titulo'
|
65
69
|
source = 'La Fuente'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hamlizer
|
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
|
- Lilibeth De La Cruz
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-07-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -91,6 +91,8 @@ files:
|
|
91
91
|
- spec/test_files/erb_on_root.html.haml
|
92
92
|
- spec/test_files/if_else.html.erb
|
93
93
|
- spec/test_files/if_else.html.haml
|
94
|
+
- spec/test_files/nested_divs_with_classes.html.erb
|
95
|
+
- spec/test_files/nested_divs_with_classes.html.haml
|
94
96
|
- spec/test_files/spaces.html.erb
|
95
97
|
- spec/test_files/spaces.html.haml
|
96
98
|
- spec/test_files/with_extra_line_breaks.haml
|
@@ -115,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
117
|
version: '0'
|
116
118
|
requirements: []
|
117
119
|
rubyforge_project:
|
118
|
-
rubygems_version: 2.
|
120
|
+
rubygems_version: 2.2.2
|
119
121
|
signing_key:
|
120
122
|
specification_version: 4
|
121
123
|
summary: HTML/ERB to HAML converter
|
@@ -129,6 +131,8 @@ test_files:
|
|
129
131
|
- spec/test_files/erb_on_root.html.haml
|
130
132
|
- spec/test_files/if_else.html.erb
|
131
133
|
- spec/test_files/if_else.html.haml
|
134
|
+
- spec/test_files/nested_divs_with_classes.html.erb
|
135
|
+
- spec/test_files/nested_divs_with_classes.html.haml
|
132
136
|
- spec/test_files/spaces.html.erb
|
133
137
|
- spec/test_files/spaces.html.haml
|
134
138
|
- spec/test_files/with_extra_line_breaks.haml
|