Module: TimelineRails::ViewHelpers
- Includes:
- ActionView::Context, ActionView::Helpers::CaptureHelper, ActionView::Helpers::OutputSafetyHelper
- Defined in:
- lib/timeline_rails/view_helpers.rb
Instance Method Summary collapse
- #timeline_block(date: nil, title: nil, preview: nil, url: nil, &block) ⇒ Object
- #timeline_wrapper(&block) ⇒ Object
Instance Method Details
#timeline_block(date: nil, title: nil, preview: nil, url: nil, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/timeline_rails/view_helpers.rb', line 16 def timeline_block(date: nil, title: nil, preview: nil, url: nil, &block) if block_given? capture(&block).html_safe else "<div class=\"timeline-block\"> <div class=\"timeline-circle\"> <span>#{date.strftime('%d/%m')}</span> </div> <a href=\"#{url}\"> <div class=\"timeline-content\"> <h2>#{title}</h2> <p>#{preview}</p> <span class=\"cd-date\">#{::I18n.l date, format: :short}</span> </div> </a> </div>".html_safe end end |
#timeline_wrapper(&block) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/timeline_rails/view_helpers.rb', line 9 def timeline_wrapper(&block) output = '<div class="timeline">' output << capture(&block) if block_given? output << '</div>' output.html_safe end |