Module: Renalware::ArticleHelper
- Defined in:
- app/helpers/renalware/article_helper.rb
Instance Method Summary collapse
-
#article_tag(title = nil, options = nil, &block) ⇒ Object
Renders: <article> <header> <h1></h1> </header> [yielded content] </article>.
-
#collection_count(collection) ⇒ Object
Renders <span>5 of 16<div> if the collection has been paginated, otherwise <span>5<div>.
Instance Method Details
#article_tag(title = nil, options = nil, &block) ⇒ Object
Renders: <article>
<header>
<h1>[title]</h1>
</header>
[yielded content]
</article>
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/helpers/renalware/article_helper.rb', line 12 def article_tag(title = nil, = nil, &block) output = tag(:article, , 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 |
#collection_count(collection) ⇒ Object
Renders <span>5 of 16<div> if the collection has been paginated, otherwise <span>5<div>
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/renalware/article_helper.rb', line 29 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 |