Sha256: 4f2795abf67fb6dc5fdd8ca51f2443db66bc362534312650aaf100ee826b82b9
Contents?: true
Size: 795 Bytes
Versions: 3
Compression:
Stored size: 795 Bytes
Contents
module PandaCms module EditorJs module Blocks class List < Base def render list_type = (data["style"] == "ordered") ? "ol" : "ul" html_safe( "<#{list_type}>" \ "#{render_items(data["items"])}" \ "</#{list_type}>" ) end private def render_items(items) items.map do |item| content = item.is_a?(Hash) ? item["content"] : item nested = (item.is_a?(Hash) && item["items"].present?) ? render_nested(item["items"]) : "" "<li>#{sanitize(content)}#{nested}</li>" end.join end def render_nested(items) self.class.new({"items" => items, "style" => data["style"]}).render end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
panda_cms-0.6.3 | app/lib/panda_cms/editor_js/blocks/list.rb |
panda_cms-0.6.2 | app/lib/panda_cms/editor_js/blocks/list.rb |
panda_cms-0.6.1 | app/lib/panda_cms/editor_js/blocks/list.rb |