Sha256: ce45eda966421eaaee27a1c94499d239896829f2eb8c91413819fcb4cf2d84f2

Contents?: true

Size: 1.03 KB

Versions: 18

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Renalware
  module ArticleHelper
    # Renders:
    # <article>
    #   <header>
    #     <h1>[title]</h1>
    #   </header>
    #   [yielded content]
    # </article>
    def article_tag(title = nil, options = nil, &block)
      output = tag(:article, options, true)
      if title.present?
        output.safe_concat(
          tag.header do
            tag.h1(title)
          end
        )
      end
      output.concat(capture(&block)) if block_given?
      output.safe_concat("</article>")
    end

    # Renders
    # <span>5 of 16<div>
    # if the collection has been paginated, otherwise
    # <span>5<div>
    def collection_count(collection)
      return unless collection&.respond_to?(:length)

      parts = ["("]
      parts.append(collection.length)
      if collection.respond_to?(:total_count)
        if collection.total_count > collection.length
          parts.append(" of #{collection.total_count}")
        end
      end
      parts.append(")")
      tag.span(parts.join(""))
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/helpers/renalware/article_helper.rb
renalware-core-2.1.0 app/helpers/renalware/article_helper.rb
renalware-core-2.0.167 app/helpers/renalware/article_helper.rb
renalware-core-2.0.166 app/helpers/renalware/article_helper.rb
renalware-core-2.0.165 app/helpers/renalware/article_helper.rb
renalware-core-2.0.164 app/helpers/renalware/article_helper.rb
renalware-core-2.0.163 app/helpers/renalware/article_helper.rb
renalware-core-2.0.162 app/helpers/renalware/article_helper.rb
renalware-core-2.0.161 app/helpers/renalware/article_helper.rb
renalware-core-2.0.160 app/helpers/renalware/article_helper.rb
renalware-core-2.0.159 app/helpers/renalware/article_helper.rb
renalware-core-2.0.158 app/helpers/renalware/article_helper.rb
renalware-core-2.0.157 app/helpers/renalware/article_helper.rb
renalware-core-2.0.156 app/helpers/renalware/article_helper.rb
renalware-core-2.0.155 app/helpers/renalware/article_helper.rb
renalware-core-2.0.153 app/helpers/renalware/article_helper.rb
renalware-core-2.0.152 app/helpers/renalware/article_helper.rb
renalware-core-2.0.151 app/helpers/renalware/article_helper.rb