prismic.io 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/prismic/fragments/slices.rb +8 -2
- data/lib/prismic/json_parsers.rb +1 -3
- data/lib/prismic/version.rb +1 -1
- data/spec/fragments_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d224afd3ee32524169fdee262f95d3f2893749af
|
4
|
+
data.tar.gz: 2c3d874f6c67bff9022a9cf789d3b832c72cd786
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfcd6341947039e5e6999fa8bfcd360d6d57c6384dee9eed32440913a20e29325cb9e988555760310eaaad8021089643db0e064cef543db422ead2d4c1b30c9d
|
7
|
+
data.tar.gz: 6cde1dedf707faaf56c737e3169f4b420f3698f210585dec7b33a1cb004bf9ce92687f77e9777abe2e1d0af4ba24cdaf6c5a522acf08276d52016d565e2b2071
|
data/Gemfile.lock
CHANGED
@@ -5,10 +5,12 @@ module Prismic
|
|
5
5
|
# A fragment of type Slice, an item in a SliceZone
|
6
6
|
class Slice < Fragment
|
7
7
|
attr_accessor :slice_type
|
8
|
+
attr_accessor :label
|
8
9
|
attr_accessor :value
|
9
10
|
|
10
|
-
def initialize(slice_type, value)
|
11
|
+
def initialize(slice_type, label, value)
|
11
12
|
@slice_type = slice_type
|
13
|
+
@label = label
|
12
14
|
@value = value
|
13
15
|
end
|
14
16
|
|
@@ -26,7 +28,11 @@ module Prismic
|
|
26
28
|
#
|
27
29
|
# @return [String] the HTML representation
|
28
30
|
def as_html(link_resolver=nil)
|
29
|
-
|
31
|
+
classes = ['slice']
|
32
|
+
unless (@label.nil?)
|
33
|
+
classes.push(@label)
|
34
|
+
end
|
35
|
+
%[<div data-slicetype="#{@slice_type}" class="#{classes.join(' ')}">#{@value.as_html(link_resolver)}</div>]
|
30
36
|
end
|
31
37
|
end
|
32
38
|
|
data/lib/prismic/json_parsers.rb
CHANGED
@@ -203,9 +203,7 @@ module Prismic
|
|
203
203
|
def slices_parser(json)
|
204
204
|
slices = []
|
205
205
|
json['value'].each do |data|
|
206
|
-
|
207
|
-
fragment = data['value']
|
208
|
-
slices << Prismic::Fragments::Slice.new(slice_type, fragment_parser(fragment))
|
206
|
+
slices << Prismic::Fragments::Slice.new(data['slice_type'], data['label'], fragment_parser(data['value']))
|
209
207
|
end
|
210
208
|
Prismic::Fragments::SliceZone.new(slices)
|
211
209
|
end
|
data/lib/prismic/version.rb
CHANGED
data/spec/fragments_spec.rb
CHANGED
@@ -713,7 +713,7 @@ describe 'Slices' do
|
|
713
713
|
|
714
714
|
it 'parses correctly' do
|
715
715
|
@slices.as_text.should == "\nc'est un bloc features\nC'est un bloc content"
|
716
|
-
@slices.as_html(@link_resolver).should == %[<section data-field="illustration"><img src="https://wroomdev.s3.amazonaws.com/toto/db3775edb44f9818c54baa72bbfc8d3d6394b6ef_hsf_evilsquall.jpg" alt="" width="4285" height="709" /></section>\n<section data-field="title"><span class="text">c
|
716
|
+
@slices.as_html(@link_resolver).gsub(''', "'").should == %[<div data-slicetype="features" class="slice"><section data-field="illustration"><img src="https://wroomdev.s3.amazonaws.com/toto/db3775edb44f9818c54baa72bbfc8d3d6394b6ef_hsf_evilsquall.jpg" alt="" width="4285" height="709" /></section>\n<section data-field="title"><span class="text">c'est un bloc features</span></section></div>\n<div data-slicetype="text" class="slice"><p>C'est un bloc content</p></div>]
|
717
717
|
end
|
718
718
|
|
719
719
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prismic.io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Étienne Vallette d'Osia
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-07-
|
14
|
+
date: 2015-07-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|