hamlit 0.6.0 → 0.6.1
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 +5 -0
- data/README.md +1 -1
- data/lib/hamlit/parser.rb +3 -2
- data/lib/hamlit/version.rb +1 -1
- data/spec/hamlit/engine_spec.rb +39 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c08c9aec751d231ce8bfa1c8a2f47ee8f7d3be0
|
4
|
+
data.tar.gz: 479dc3dac50ba716b8a77a78b52e334a8d670b9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 068959a68a071911879281fbe37e5d7b8c5feca7b8b7e4529396dcc71f99d2e127b3d4f600dc5b5edcd0ed244033976e20216f8dea58fdbe45a63a2404e6ac1a
|
7
|
+
data.tar.gz: a9680ba6c4321d62f48edaf7deb83e7c90e1d2ca53e0de234440abd85c5dd0ccc3011f31d4e636d651c4accf02b01eb30a99034640a2599789bc3a16a294100c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -41,7 +41,7 @@ so it is able to parse such an attribute.
|
|
41
41
|
### Passing haml-spec
|
42
42
|
|
43
43
|
[haml/haml-spec](https://github.com/haml/haml-spec) is a basic suite of tests for Haml interpreters.
|
44
|
-
For all test cases in haml-spec, Hamlit behaves the same as Haml (ugly mode only, which is used on production).
|
44
|
+
For all test cases in haml-spec, Hamlit behaves the same as Haml (ugly and escape\_html mode only, which is used on production).
|
45
45
|
|
46
46
|
Hamlit is used on [githubranking.com](http://githubranking.com/).
|
47
47
|
|
data/lib/hamlit/parser.rb
CHANGED
@@ -55,7 +55,7 @@ module Hamlit
|
|
55
55
|
width = next_width
|
56
56
|
if width != @current_indent * 2
|
57
57
|
if width != Hamlit::EOF && (width > @current_indent * 2 || width.odd?)
|
58
|
-
ast << [:
|
58
|
+
ast << [:newline]
|
59
59
|
ast << syntax_error(
|
60
60
|
"inconsistent indentation: #{2 * @current_indent} spaces used for indentation, "\
|
61
61
|
"but the rest of the document was indented using #{width} spaces"
|
@@ -69,8 +69,9 @@ module Hamlit
|
|
69
69
|
if @outer_removal.include?(@current_indent) && ast.last == [:static, "\n"]
|
70
70
|
ast.delete_at(-1)
|
71
71
|
end
|
72
|
+
ast << [:newline] if @current_indent > 0
|
72
73
|
ast << node
|
73
|
-
ast << [:newline]
|
74
|
+
ast << [:newline] if @current_indent == 0
|
74
75
|
ast << [:static, "\n"] unless skip_newline?(node)
|
75
76
|
end
|
76
77
|
ast
|
data/lib/hamlit/version.rb
CHANGED
data/spec/hamlit/engine_spec.rb
CHANGED
@@ -16,4 +16,43 @@ describe Hamlit::Engine do
|
|
16
16
|
)
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
describe '#call' do
|
21
|
+
let(:haml) do
|
22
|
+
<<-HAML.unindent
|
23
|
+
!!! html
|
24
|
+
|
25
|
+
%html
|
26
|
+
%head
|
27
|
+
%title Simple Haml
|
28
|
+
%body
|
29
|
+
%h1= 'header'
|
30
|
+
- unless false
|
31
|
+
%ul
|
32
|
+
- for i in [1, 2, 3]
|
33
|
+
- if i
|
34
|
+
%li
|
35
|
+
%strong= 'hello'
|
36
|
+
- else
|
37
|
+
%li
|
38
|
+
%a{:href => i}= i
|
39
|
+
- else
|
40
|
+
%p last line
|
41
|
+
HAML
|
42
|
+
end
|
43
|
+
let(:engine) { described_class.new }
|
44
|
+
|
45
|
+
it 'generates code with the same lineno as a template' do
|
46
|
+
lines = engine.call(haml).split("\n")
|
47
|
+
expect(lines[0]).to include('DOCTYPE')
|
48
|
+
expect(lines[6]).to include('header')
|
49
|
+
expect(lines[7]).to include('unless')
|
50
|
+
expect(lines[9]).to include('for i in')
|
51
|
+
expect(lines[10]).to include('if i')
|
52
|
+
expect(lines[12]).to include('hello')
|
53
|
+
expect(lines[13]).to include('else')
|
54
|
+
expect(lines[16]).to include('else')
|
55
|
+
expect(lines[17]).to include('last line')
|
56
|
+
end
|
57
|
+
end
|
19
58
|
end
|