Sha256: d9301b408e493e0d77f60cc250c4fd14b36928164e8f4e1cecb4d8269ebc045e

Contents?: true

Size: 468 Bytes

Versions: 9

Compression:

Stored size: 468 Bytes

Contents

module Pakyow
  module Presenter
    class StringDocRenderer
      def self.render(structure)
        structure.flatten.reject(&:empty?).map { |s|
          s.is_a?(Hash) ? attrify(s) : s
        }.join
      end

      IGNORED_ATTRS = %i[container partial]
      def self.attrify(attrs)
        attrs.delete_if { |a| a.nil? || IGNORED_ATTRS.include?(a) }.map { |attr|
          attr[0].to_s + '="' + attr[1].to_s + '"'
        }.join(' ')
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pakyow-presenter-0.11.3 pakyow-presenter/lib/pakyow/presenter/string_doc_renderer.rb
pakyow-presenter-0.11.2 pakyow-presenter/lib/pakyow/presenter/string_doc_renderer.rb
pakyow-presenter-0.11.1 pakyow-presenter/lib/pakyow/presenter/string_doc_renderer.rb
pakyow-presenter-0.11.0 pakyow-presenter/lib/pakyow/presenter/string_doc_renderer.rb
pakyow-presenter-0.10.2 pakyow-presenter/lib/presenter/string_doc_renderer.rb
pakyow-presenter-0.10.1 pakyow-presenter/lib/presenter/string_doc_renderer.rb
pakyow-presenter-0.10.0 pakyow-presenter/lib/presenter/string_doc_renderer.rb
pakyow-presenter-0.9.1 pakyow-presenter/lib/presenter/string_doc_renderer.rb
pakyow-presenter-0.9.0 pakyow-presenter/lib/presenter/string_doc_renderer.rb