class Prismic::Fragments::CompositeSlice
A fragment of type CompositeSlice
, an item in a SliceZone
Attributes
non_repeat[RW]
repeat[RW]
slice_label[RW]
slice_type[RW]
Public Class Methods
new(slice_type, slice_label, non_repeat, repeat)
click to toggle source
# File lib/prismic/fragments/slices.rb, line 12 def initialize(slice_type, slice_label, non_repeat, repeat) @slice_type = slice_type @slice_label = slice_label @non_repeat = non_repeat @repeat = repeat end
Public Instance Methods
as_html(link_resolver=nil)
click to toggle source
Generate an HTML representation of the group
@param link_resolver [LinkResolver] The LinkResolver
used to build
application's specific URL
@return [String] the HTML representation
# File lib/prismic/fragments/slices.rb, line 37 def as_html(link_resolver=nil) classes = ['slice'] unless (@slice_label.nil?) classes.push(@slice_label) end non_repeat_html = '' @non_repeat.each do |fragment_key, fragment_value| non_repeat_html += fragment_value.as_html(link_resolver) end repeat_html = repeat.as_html(link_resolver) %[<div data-slicetype="#{@slice_type}" class="#{classes.join(' ')}">#{non_repeat_html + repeat_html}</div>] end
as_text()
click to toggle source
Generate an text representation of the group
@return [String] the text representation
# File lib/prismic/fragments/slices.rb, line 22 def as_text non_repeat_text = '' @non_repeat.each do |fragment_key, fragment_value| non_repeat_text += fragment_value.as_text end "#{non_repeat_text}\n#{@repeat.as_text}" end