haml_parser 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/haml_parser/ast.rb +2 -8
- data/lib/haml_parser/parser.rb +7 -12
- data/lib/haml_parser/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2018bdc583b86d3e184e4f98d1ac356d41641ef7
|
4
|
+
data.tar.gz: ce85adf4d59e27557bfa16670094a771be76d6bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adf34f95177de3d6cedc65536405fe387b5b9ff10ffd9b7a3fc21344731d692253468629ddc87aa2b2d536163462e71e3323f529710f402fd05375e9cef98b28
|
7
|
+
data.tar.gz: 5cee1370ebfa90524568fec5948549b7cbd890872eb6a538ba7c5825e5d12450859ff5b3547da54d94fb31e7d3cad29570fefbc7b9fa192269135c49a89db75a
|
data/CHANGELOG.md
CHANGED
data/lib/haml_parser/ast.rb
CHANGED
@@ -65,6 +65,7 @@ module HamlParser
|
|
65
65
|
Script = Struct.new(
|
66
66
|
:children,
|
67
67
|
:script,
|
68
|
+
:keyword,
|
68
69
|
:escape_html,
|
69
70
|
:preserve,
|
70
71
|
:filename,
|
@@ -87,16 +88,9 @@ module HamlParser
|
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
90
|
-
SilentScript = Struct.new(:children, :script, :
|
91
|
+
SilentScript = Struct.new(:children, :script, :keyword, :filename, :lineno) do
|
91
92
|
include HasChildren
|
92
93
|
|
93
|
-
def initialize(*)
|
94
|
-
super
|
95
|
-
if mid_block_keyword.nil?
|
96
|
-
self.mid_block_keyword = false
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
94
|
def to_h
|
101
95
|
super.merge(type: 'silent_script')
|
102
96
|
end
|
data/lib/haml_parser/parser.rb
CHANGED
@@ -141,7 +141,11 @@ module HamlParser
|
|
141
141
|
end
|
142
142
|
|
143
143
|
def parse_script(text)
|
144
|
-
|
144
|
+
node = ScriptParser.new(@line_parser).parse(text)
|
145
|
+
if node.is_a?(Ast::Script)
|
146
|
+
node.keyword = block_keyword(node.script)
|
147
|
+
end
|
148
|
+
@ast << node
|
145
149
|
end
|
146
150
|
|
147
151
|
def parse_silent_script(text)
|
@@ -152,6 +156,7 @@ module HamlParser
|
|
152
156
|
node = create_node(Ast::SilentScript)
|
153
157
|
script = text[/\A- *(.*)\z/, 1]
|
154
158
|
node.script = [script, *RubyMultiline.read(@line_parser, script)].join("\n")
|
159
|
+
node.keyword = block_keyword(node.script)
|
155
160
|
@ast << node
|
156
161
|
end
|
157
162
|
|
@@ -191,14 +196,8 @@ module HamlParser
|
|
191
196
|
nil
|
192
197
|
end
|
193
198
|
|
194
|
-
def indent_leave(
|
199
|
+
def indent_leave(_indent_level, _text)
|
195
200
|
parent_ast = @stack.pop
|
196
|
-
case @ast
|
197
|
-
when Ast::SilentScript
|
198
|
-
if indent_level == @indent_tracker.current_level
|
199
|
-
@ast.mid_block_keyword = mid_block_keyword?(text)
|
200
|
-
end
|
201
|
-
end
|
202
201
|
@ast = parent_ast
|
203
202
|
nil
|
204
203
|
end
|
@@ -216,10 +215,6 @@ module HamlParser
|
|
216
215
|
end
|
217
216
|
end
|
218
217
|
|
219
|
-
def mid_block_keyword?(text)
|
220
|
-
MID_BLOCK_KEYWORDS.include?(block_keyword(text))
|
221
|
-
end
|
222
|
-
|
223
218
|
def syntax_error!(message)
|
224
219
|
raise Error.new(message, @line_parser.lineno)
|
225
220
|
end
|
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.2.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
|
+
date: 2015-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
191
|
version: '0'
|
192
192
|
requirements: []
|
193
193
|
rubyforge_project:
|
194
|
-
rubygems_version: 2.5.
|
194
|
+
rubygems_version: 2.4.5.1
|
195
195
|
signing_key:
|
196
196
|
specification_version: 4
|
197
197
|
summary: Parser of Haml template language
|