Module: HeadingWithTitle::Helpers
- Defined in:
- lib/heading_with_title/helpers.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#heading_with_title(arg = nil, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/heading_with_title/helpers.rb', line 16 def heading_with_title(arg = nil, &block) heading = case arg when NilClass t(HeadingWithTitle.default_i18n_key) when Hash t(HeadingWithTitle.default_i18n_key, arg) when String arg when ActiveRecord::Base arg.to_s else raise ArgumentError, 'Incorrect arguments for heading_with_title!' end page_title(heading) if block_given? content = capture(heading, &block) heading = raw(content) end content_tag(HeadingWithTitle.default_heading_size, heading) end |
#page_title(title = nil) ⇒ Object
Set page title. Use this method in your views
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/heading_with_title/helpers.rb', line 5 def page_title(title = nil) if title.present? @hwt_title = title nil else suffix = HeadingWithTitle.title_suffix suffix = suffix.call if suffix.is_a?(Proc) raw ([@hwt_title, suffix].compact.join(HeadingWithTitle.title_delimeter)) end end |