haml2slim 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/haml2slim/converter.rb +20 -12
- data/lib/haml2slim/version.rb +1 -1
- metadata +2 -2
data/lib/haml2slim/converter.rb
CHANGED
@@ -16,26 +16,34 @@ module Haml2Slim
|
|
16
16
|
indent = line[/^[ \t]*/]
|
17
17
|
line.strip!
|
18
18
|
|
19
|
-
converted = case line[0]
|
20
|
-
when
|
21
|
-
when
|
22
|
-
when
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
converted = case line[0, 2]
|
20
|
+
when '&=' then line.sub(/^&=/, '==')
|
21
|
+
when '!=' then line.sub(/^!=/, '=')
|
22
|
+
when '-#' then line.sub(/^-#/, '/')
|
23
|
+
else
|
24
|
+
case line[0]
|
25
|
+
when ?%, ?., ?# then parse_tag(line)
|
26
|
+
when ?: then "#{line[1..-1]}:"
|
27
|
+
when ?! then line.sub(/^!!!/, '! doctype')
|
28
|
+
when ?-, ?= then line
|
29
|
+
when ?~ then line.sub(/^~/, '=')
|
30
|
+
when ?/ then line
|
31
|
+
when ?\ then line.sub(/^\\/, '|')
|
32
|
+
when nil then ""
|
33
|
+
else "| #{line}"
|
34
|
+
end
|
27
35
|
end
|
28
36
|
|
29
|
-
if converted.chomp!(
|
30
|
-
converted.sub!(/^\| /,
|
31
|
-
converted <<
|
37
|
+
if converted.chomp!(' |')
|
38
|
+
converted.sub!(/^\| /, '')
|
39
|
+
converted << ' \\'
|
32
40
|
end
|
33
41
|
|
34
42
|
"#{indent}#{converted}\n"
|
35
43
|
end
|
36
44
|
|
37
45
|
def parse_tag(tag_line)
|
38
|
-
tag_line.sub!(/^%/,
|
46
|
+
tag_line.sub!(/^%/, '')
|
39
47
|
|
40
48
|
if tag_line_contains_attr = tag_line.match(/(.+)\{(.+)\}/)
|
41
49
|
tag, attrs = *tag_line_contains_attr[1..2]
|
data/lib/haml2slim/version.rb
CHANGED