Module: Plutonium::Helpers::ContentHelper
- Defined in:
- lib/plutonium/helpers/content_helper.rb
Instance Method Summary collapse
- #clamp_content(content) ⇒ Object
- #quill(content) ⇒ Object
- #read_more(content, clamp = 4) ⇒ Object
- #timeago(date, format: :long) ⇒ Object
Instance Method Details
#clamp_content(content) ⇒ Object
59 60 61 62 63 |
# File 'lib/plutonium/helpers/content_helper.rb', line 59 def clamp_content(content) return if content.blank? tag.div content, class: "clamped-content" end |
#quill(content) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/plutonium/helpers/content_helper.rb', line 47 def quill(content) return if content.blank? tag.div( content, class: "ql-viewer", data: { controller: "quill-viewer" } ) end |
#read_more(content, clamp = 4) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/plutonium/helpers/content_helper.rb', line 21 def read_more(content, clamp = 4) return if content.blank? # Stimulus Read More (https://www.stimulus-components.com/docs/stimulus-read-more/) style = "overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; " \ "-webkit-line-clamp: var(--read-more-line-clamp, #{clamp});" tag.div( data: { controller: "read-more", read_more_more_text_value: "Read more", read_more_less_text_value: "Read less" } ) do concat tag.div(content, style:, data: {read_more_target: "content"}) next unless content.lines.size > clamp concat tag.("Read more", class: "btn btn-sm btn-link text-decoration-none ps-0", data: {action: "read-more#toggle"}) end end |
#timeago(date, format: :long) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/plutonium/helpers/content_helper.rb', line 4 def timeago(date, format: :long) return if date.blank? content = I18n.l(date, format:) tag.time( content, title: content, data: { controller: "timeago", timeago_refresh_interval_value: 1000, timeago_include_seconds_value: true, timeago_add_suffix_value: true, timeago_datetime_value: date.iso8601 } ) end |