haml_parser 0.2.0 → 0.3.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/CHANGELOG.md +4 -0
- data/lib/haml_parser/ast.rb +1 -0
- data/lib/haml_parser/element_parser.rb +26 -8
- data/lib/haml_parser/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: 57fa4126042491041d5f4331f41515d43c83a589
|
4
|
+
data.tar.gz: 56cbec56b038d88ea9f624fb8f77e8d802adb0cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a959f007b23c072abf2521e3ad6a7ea6684b5dec4cd975cea09030fa43dcbded2505827c2c82f9fbe808e3dea0ae1c6a8d03388c126fdaaaf9357e730a670112
|
7
|
+
data.tar.gz: 72ec32afa7ee002abde26b19538ae2429d04afe55fe4d60b9bcf04155e8ff8486c545ad9d5a5375f657100d6597eb775f590d0baabe935dbb940abbe287a9e3e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# 0.3.0 (2015-11-16)
|
2
|
+
- Add support for object reference syntax
|
3
|
+
- Fix attribute parser for empty braces or parens
|
4
|
+
|
1
5
|
# 0.2.0 (2015-11-15)
|
2
6
|
- Remove `Ast::SilentScript#mid_block_keyword` attribute
|
3
7
|
- Add `Ast::Script#keyword` and `Ast::SilentScript#keyword` attribute
|
data/lib/haml_parser/ast.rb
CHANGED
@@ -26,7 +26,7 @@ module HamlParser
|
|
26
26
|
element.static_class, element.static_id = parse_class_and_id(m[2])
|
27
27
|
rest = m[3] || ''
|
28
28
|
|
29
|
-
element.attributes, rest = parse_attributes(rest)
|
29
|
+
element.attributes, element.object_ref, rest = parse_attributes(rest)
|
30
30
|
element.nuke_inner_whitespace, element.nuke_outer_whitespace, rest = parse_nuke_whitespace(rest)
|
31
31
|
element.self_closing, rest = parse_self_closing(rest)
|
32
32
|
element.oneline_child = ScriptParser.new(@line_parser).parse(rest)
|
@@ -57,37 +57,44 @@ module HamlParser
|
|
57
57
|
|
58
58
|
OLD_ATTRIBUTE_BEGIN = '{'
|
59
59
|
NEW_ATTRIBUTE_BEGIN = '('
|
60
|
+
OBJECT_REF_BEGIN = '['
|
60
61
|
|
61
62
|
def parse_attributes(rest)
|
62
|
-
old_attributes =
|
63
|
-
new_attributes =
|
63
|
+
old_attributes = nil
|
64
|
+
new_attributes = nil
|
65
|
+
object_ref = nil
|
64
66
|
|
65
67
|
loop do
|
66
68
|
case rest[0]
|
67
69
|
when OLD_ATTRIBUTE_BEGIN
|
68
|
-
|
70
|
+
if old_attributes
|
69
71
|
break
|
70
72
|
end
|
71
73
|
old_attributes, rest = parse_old_attributes(rest)
|
72
74
|
when NEW_ATTRIBUTE_BEGIN
|
73
|
-
|
75
|
+
if new_attributes
|
74
76
|
break
|
75
77
|
end
|
76
78
|
new_attributes, rest = parse_new_attributes(rest)
|
79
|
+
when OBJECT_REF_BEGIN
|
80
|
+
if object_ref
|
81
|
+
break
|
82
|
+
end
|
83
|
+
object_ref, rest = parse_object_ref(rest)
|
77
84
|
else
|
78
85
|
break
|
79
86
|
end
|
80
87
|
end
|
81
88
|
|
82
|
-
attributes = old_attributes
|
83
|
-
|
89
|
+
attributes = old_attributes || ''
|
90
|
+
if new_attributes
|
84
91
|
if attributes.empty?
|
85
92
|
attributes = new_attributes
|
86
93
|
else
|
87
94
|
attributes << ', ' << new_attributes
|
88
95
|
end
|
89
96
|
end
|
90
|
-
[attributes, rest]
|
97
|
+
[attributes, object_ref, rest]
|
91
98
|
end
|
92
99
|
|
93
100
|
def parse_old_attributes(text)
|
@@ -204,6 +211,17 @@ module HamlParser
|
|
204
211
|
end
|
205
212
|
end
|
206
213
|
|
214
|
+
def parse_object_ref(text)
|
215
|
+
s = StringScanner.new(text)
|
216
|
+
s.pos = 1
|
217
|
+
depth = Utils.balance(s, '[', ']')
|
218
|
+
if depth == 0
|
219
|
+
[s.pre_match[1, s.pre_match.size - 1], s.rest]
|
220
|
+
else
|
221
|
+
syntax_error!('Unmatched brackets for object reference')
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
207
225
|
def parse_nuke_whitespace(rest)
|
208
226
|
m = rest.match(/\A(><|<>|[><])(.*)\z/)
|
209
227
|
if m
|
data/lib/haml_parser/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kohei Suzuki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|