faml 0.2.4 → 0.2.5
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/faml/static_hash_parser.rb +8 -2
- data/lib/faml/version.rb +1 -1
- data/spec/render/attribute_spec.rb +9 -0
- 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: f5be22673d059f3065d3e748acab1499879a0808
|
4
|
+
data.tar.gz: 493d64d87e95ee62a3f2567a60233de635a7ab69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed6b5e9ef55122c50b410dc412f403f781a80ba99193f415a3eb8a6a188598e6861a8afb71362733acb71039856c4fc3d5fb7e9710e337f5cde92882eba5ca3f
|
7
|
+
data.tar.gz: bca6c7834c44dab97238d108da0ee99db1f9152c15e6609e5e506ac2af6039b208c8aee57aab5bff4479ed27d5469810fb85ea83fd0f99a9164705ee9dde1c4d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 0.2.5 (2015-03-30)
|
2
|
+
- Fix parser when parsing attributes in `{'foo': 'bar'}` form
|
3
|
+
- The syntax was introduced in Ruby 2.2.
|
4
|
+
|
1
5
|
## 0.2.4 (2015-03-26)
|
2
6
|
- Fix parser when parsing `>` or `<` after attribute lists
|
3
7
|
- `%div{foo: :bar} <br>` was incorrectly parsed as `%div{foo: :bar}< br>` .
|
@@ -56,9 +56,15 @@ module Faml
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
SYMBOL_FIRST_CHARS = [
|
60
|
+
':', # { :'foo' => 'bar' } or { :"foo" => 'bar' }
|
61
|
+
"'", # { 'foo': 'bar' }
|
62
|
+
'"', # { "foo": 'bar' }
|
63
|
+
].freeze
|
64
|
+
|
59
65
|
def eval_symbol(code)
|
60
|
-
if
|
61
|
-
eval(code)
|
66
|
+
if SYMBOL_FIRST_CHARS.include?(code[0])
|
67
|
+
eval(code).to_sym
|
62
68
|
else
|
63
69
|
code.to_sym
|
64
70
|
end
|
data/lib/faml/version.rb
CHANGED
@@ -19,6 +19,15 @@ RSpec.describe 'Attributes rendering', type: :render do
|
|
19
19
|
expect(render_string("%span{:'foo-bar' => 'baz'}")).to eq("<span foo-bar='baz'></span>\n")
|
20
20
|
end
|
21
21
|
|
22
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
|
23
|
+
it 'renders attributes with 2.2-style symbol literals' do
|
24
|
+
expect(render_string(%Q|%span{"foo": 'bar'}|)).to eq("<span foo='bar'></span>\n")
|
25
|
+
expect(render_string(%Q|- x = 'bar'\n%span{"foo": x}|)).to eq("<span foo='bar'></span>\n")
|
26
|
+
expect(render_string(%Q|%span{'foo': 'bar'}|)).to eq("<span foo='bar'></span>\n")
|
27
|
+
expect(render_string(%Q|- x = 'bar'\n%span{'foo': x}|)).to eq("<span foo='bar'></span>\n")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
22
31
|
it 'renders dynamic attributes' do
|
23
32
|
expect(render_string(%q|%span#main{class: "na#{'ni'}ka"} hello|)).to eq(%Q{<span class='nanika' id='main'>hello</span>\n})
|
24
33
|
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.
|
4
|
+
version: 0.2.5
|
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-03-
|
11
|
+
date: 2015-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: escape_utils
|
@@ -406,7 +406,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
406
406
|
version: '0'
|
407
407
|
requirements: []
|
408
408
|
rubyforge_project:
|
409
|
-
rubygems_version: 2.
|
409
|
+
rubygems_version: 2.4.5
|
410
410
|
signing_key:
|
411
411
|
specification_version: 4
|
412
412
|
summary: Faster implementation of Haml template language.
|