faml 0.2.10 → 0.2.11

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: 05912ba9442dfe72d17b8f1e9aacbf1484b036e7
4
- data.tar.gz: d84fdc9481afa2e31fefb7b180a45664197706a2
3
+ metadata.gz: 4090ae5210da7fc60d6ed8e2837ab25f846a8271
4
+ data.tar.gz: 60d7ddcb1e8fd8f87fc97de7341e97e5e3e6c81a
5
5
  SHA512:
6
- metadata.gz: 71e2974457f43aca89266a3dde091a0306db1f1d8c5bee5ed9a69d3efc0dde87ef5386023acf19f6864860383d01158b88aeda3a6607719c7ccababc1277fdf3
7
- data.tar.gz: a0b4b25fccb960ec88a9733fe34610e27a7d984c53fc79c3690b55a2cb508b0b7f705963877be2a79faf39f09ba3c7e48bc75167c9122b138352506dcdfdb501
6
+ metadata.gz: 3840b30af5a7e5edcf48918d91046fcd34b2982672770a5b29afca3f05833676f30dbed78fe00e5807fbe3b8ffa58fd6a2e737509e307ee544c6769cf63c93bc
7
+ data.tar.gz: 1afc3e04ae4fb23a20b9e0fb316bf5cf336c162df281165c726f2f240e494639dadc8e197d70e41bb44d0a4424de0fe6ed3b7d640f1603c0fe4819cb4448784f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.11 (2015-04-07)
2
+ - Keep code newlines within multiline in HTML-style attribute list
3
+ - https://github.com/eagletmt/faml/issues/19
4
+
1
5
  ## 0.2.10 (2015-04-06)
2
6
  - Keep code newlines within Ruby multiline
3
7
 
data/README.md CHANGED
@@ -27,6 +27,8 @@ Or install it yourself as:
27
27
  ### Rails, sinatra
28
28
  Just replace your `gem 'haml'` with `gem 'faml'` .
29
29
 
30
+ faml is only tested with Rails >= 4.0.
31
+
30
32
  ### middleman
31
33
  Since middleman has its own renderers, there's no easy way to use faml with middleman currently.
32
34
 
@@ -77,11 +77,10 @@ module Faml
77
77
 
78
78
  attributes = old_attributes
79
79
  unless new_attributes.empty?
80
- t = to_old_syntax(new_attributes)
81
80
  if attributes.empty?
82
- attributes = t
81
+ attributes = new_attributes
83
82
  else
84
- attributes << ", " << t
83
+ attributes << ", " << new_attributes
85
84
  end
86
85
  end
87
86
  [attributes, rest]
@@ -112,14 +111,12 @@ module Faml
112
111
  s = StringScanner.new(text)
113
112
  s.pos = 1
114
113
  depth = 1
115
- new_attributes = []
116
114
  loop do
117
115
  pre_pos = s.pos
118
116
  depth = ParserUtils.balance(s, '(', ')', depth)
119
117
  if depth == 0
120
118
  t = s.string.byteslice(pre_pos ... s.pos-1)
121
- new_attributes.concat(parse_new_attribute_list(t))
122
- return [new_attributes, s.rest]
119
+ return [parse_new_attribute_list(t), s.rest]
123
120
  else
124
121
  if @line_parser.has_next?
125
122
  text << "\n" << @line_parser.next_line
@@ -132,7 +129,7 @@ module Faml
132
129
 
133
130
  def parse_new_attribute_list(text)
134
131
  s = StringScanner.new(text)
135
- list = []
132
+ attributes = []
136
133
  until s.eos?
137
134
  name = scan_key(s)
138
135
  s.skip(/\s*/)
@@ -143,11 +140,12 @@ module Faml
143
140
  else
144
141
  value = 'true'
145
142
  end
146
- s.skip(/\s*/)
143
+ spaces = s.scan(/\s*/)
144
+ line_count = spaces.count("\n")
147
145
 
148
- list << [name, value]
146
+ attributes << "#{name.inspect} => #{value},#{"\n" * line_count}"
149
147
  end
150
- list
148
+ attributes.join
151
149
  end
152
150
 
153
151
  def scan_key(scanner)
@@ -201,10 +199,6 @@ module Faml
201
199
  end
202
200
  end
203
201
 
204
- def to_old_syntax(new_attributes)
205
- new_attributes.map { |k, v| "#{k.inspect} => #{v}" }.join(', ')
206
- end
207
-
208
202
  def parse_nuke_whitespace(rest)
209
203
  m = rest.match(/\A(><|<>|[><])(.*)\z/)
210
204
  if m
data/lib/faml/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Faml
2
- VERSION = "0.2.10"
2
+ VERSION = "0.2.11"
3
3
  end
@@ -168,6 +168,14 @@ HAML
168
168
  HAML
169
169
  end
170
170
 
171
+ it 'keeps newlines in static HTML-style attributes' do
172
+ expect(render_string(<<HAML)).to eq("<span a='1' b='2'></span>\n3\n")
173
+ %span(a=1
174
+ b=2)
175
+ = __LINE__
176
+ HAML
177
+ end
178
+
171
179
  it 'keeps newlines in dynamic attributes' do
172
180
  expect { render_string(<<HAML) }.to raise_error(LineVerifier, raised_at(2))
173
181
  %span{a: 1,
@@ -259,5 +259,12 @@ HAML
259
259
  it 'raises error when string interpolation is unterminated' do
260
260
  expect { render_string('%span(foo=1 bar="ba#{1") hello') }.to raise_error(Faml::SyntaxError)
261
261
  end
262
+
263
+ it 'renders __LINE__ correctly' do
264
+ expect(render_string(<<HAML)).to eq("<span a='2' b='1'></span>\n")
265
+ %span(b=__LINE__
266
+ a=__LINE__)
267
+ HAML
268
+ end
262
269
  end
263
270
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kohei Suzuki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-06 00:00:00.000000000 Z
11
+ date: 2015-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: escape_utils