hamlit 0.5.1 → 0.5.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0bfb9ad9ffecfdff23622a518e793277666c95dc
4
- data.tar.gz: 0ce26c8bf5d259d79af24b18d5c5fd4f83a4d862
3
+ metadata.gz: 5175b4fea185d08238f003ae8669fe7747418b7e
4
+ data.tar.gz: 304e17d39d4cc0a6f7c04f0688f882d8375e5969
5
5
  SHA512:
6
- metadata.gz: 04fd200583dd12ef868addaddbd6d0e85d76ffd96bd6ca29010d853acb6ffd8844ace8888d8d2948aa38379349df76ee054b53014c7bd16417af4b61f4a63426
7
- data.tar.gz: 73bfe1a5b717565904aac6e0dc1fc07bb27a44f8b1507624c607bc8a240989b8f80ebee8345c65648163f4cfe069cb4cd05d06458406805763fc23a864655cc7
6
+ metadata.gz: a45f5ebd7c99d9cd79b9651e409390cfac808b3c6cd87de51150dc86a613bf274be9183ba8328f4f8fc1af983337663641b0d784db7339074a692aecacf298fe
7
+ data.tar.gz: 064d03cfc93d24e066b6efadc24a73e422deb1a845542fb5dfe7890c1df362bcb1cbd522560258d1c86e78c185adb64e62be27df0bf4ca3fa2b7c220c400f303
@@ -1,3 +1,9 @@
1
+ ## v0.5.2
2
+
3
+ - Bugfix for silent script without block
4
+ - https://github.com/k0kubun/hamlit/issues/16
5
+ - Thanks to @eagletmt
6
+
1
7
  ## v0.5.1
2
8
 
3
9
  - Bugfix about duplicated id and class
data/README.md CHANGED
@@ -85,7 +85,6 @@ to optimize performance such as string interpolation.
85
85
  Currently there are some important incompatibilities that should be fixed.
86
86
 
87
87
  - Remove falsy attributes [#2](https://github.com/k0kubun/hamlit/issues/2)
88
- - Escape attribute values [#10](https://github.com/k0kubun/hamlit/issues/10)
89
88
 
90
89
  ## License
91
90
 
@@ -48,14 +48,19 @@ module Hamlit
48
48
  return [:multi]
49
49
  end
50
50
 
51
- ast = [:multi, [:code, scan_code(scanner)]]
51
+ code = scan_code(scanner)
52
+ ast = [:multi, [:code, code]]
52
53
  unless has_block?
53
- ast << [:code, 'end'] if @current_indent > next_indent
54
+ if internal_statement?(code) && !statement_continuing?
55
+ ast << [:code, 'end']
56
+ end
54
57
  return ast
55
58
  end
56
59
 
57
60
  ast += with_indented { parse_lines }
58
- ast << [:code, 'end'] unless same_indent?(next_line) && internal_statement?(next_line)
61
+ unless statement_continuing?
62
+ ast << [:code, 'end']
63
+ end
59
64
  ast
60
65
  end
61
66
 
@@ -93,12 +98,18 @@ module Hamlit
93
98
  next_indent == @current_indent + 1
94
99
  end
95
100
 
96
- def internal_statement?(line)
101
+ def statement_continuing?
102
+ same_indent?(next_line) && internal_statement?(next_line, silent_script: true)
103
+ end
104
+
105
+ def internal_statement?(line, silent_script: false)
97
106
  return false unless line
98
107
 
99
108
  scanner = StringScanner.new(line)
100
109
  scanner.scan(/ +/)
101
- return false unless scanner.scan(/-/)
110
+ if silent_script
111
+ return false unless scanner.scan(/-/)
112
+ end
102
113
 
103
114
  scanner.scan(/ +/)
104
115
  statement = scanner.scan(/[^ ]+/)
@@ -1,3 +1,3 @@
1
1
  module Hamlit
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
@@ -1,5 +1,14 @@
1
1
  describe Hamlit::Engine do
2
2
  describe 'silent script' do
3
+ it 'renders nothing' do
4
+ assert_render(<<-HAML, <<-HTML)
5
+ - nil
6
+ - 3
7
+ - 'foo'
8
+ HAML
9
+ HTML
10
+ end
11
+
3
12
  it 'renders silent script' do
4
13
  assert_render(<<-HAML, <<-HTML)
5
14
  - foo = 3
@@ -67,6 +76,17 @@ describe Hamlit::Engine do
67
76
  HTML
68
77
  end
69
78
 
79
+ it 'renders empty elsif statement' do
80
+ assert_render(<<-'HAML', <<-HTML)
81
+ %span
82
+ - if false
83
+ - elsif false
84
+ HAML
85
+ <span>
86
+ </span>
87
+ HTML
88
+ end
89
+
70
90
  it 'renders empty else statement' do
71
91
  assert_render(<<-'HAML', <<-HTML)
72
92
  %span
@@ -79,6 +99,17 @@ describe Hamlit::Engine do
79
99
  HTML
80
100
  end
81
101
 
102
+ it 'renders empty when statement' do
103
+ assert_render(<<-'HAML', <<-HTML)
104
+ %span
105
+ - case
106
+ - when false
107
+ HAML
108
+ <span>
109
+ </span>
110
+ HTML
111
+ end
112
+
82
113
  it 'accept if inside if-else' do
83
114
  assert_render(<<-'HAML', <<-HTML)
84
115
  - if false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hamlit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun