Sha256: 821b3a85157d6b80c12d0b46542a0b996c2221939411ac48171b845bfdca35a0
Contents?: true
Size: 1.06 KB
Versions: 34
Compression:
Stored size: 1.06 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( content_tag("header") do content_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(")") content_tag("span", parts.join("")) end end end
Version data entries
34 entries across 34 versions & 1 rubygems