Class: ContentTagHelper::Tag
- Inherits:
-
Object
- Object
- ContentTagHelper::Tag
- Includes:
- ActionView::Helpers::CaptureHelper
- Defined in:
- lib/ecrire/app/helpers/content_tag_helper.rb
Defined Under Namespace
Classes: CSS
Instance Attribute Summary collapse
-
#css ⇒ Object
readonly
Returns the value of attribute css.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #[](k) ⇒ Object
- #[]=(k, v) ⇒ Object
-
#initialize(name, *args) ⇒ Tag
constructor
A new instance of Tag.
- #render(content) ⇒ Object
- #render_attributes ⇒ Object
- #tag_options(*args) ⇒ Object
Constructor Details
Instance Attribute Details
#css ⇒ Object (readonly)
Returns the value of attribute css.
21 22 23 |
# File 'lib/ecrire/app/helpers/content_tag_helper.rb', line 21 def css @css end |
#id ⇒ Object
Returns the value of attribute id.
20 21 22 |
# File 'lib/ecrire/app/helpers/content_tag_helper.rb', line 20 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
21 22 23 |
# File 'lib/ecrire/app/helpers/content_tag_helper.rb', line 21 def name @name end |
Instance Method Details
#[](k) ⇒ Object
44 45 46 |
# File 'lib/ecrire/app/helpers/content_tag_helper.rb', line 44 def [](k) @attributes[k] end |
#[]=(k, v) ⇒ Object
48 49 50 |
# File 'lib/ecrire/app/helpers/content_tag_helper.rb', line 48 def []=(k,v) @attributes[k] = v end |
#render(content) ⇒ Object
52 53 54 |
# File 'lib/ecrire/app/helpers/content_tag_helper.rb', line 52 def render(content) "<#{name}#{render_attributes}>#{content.to_s.strip}</#{name}>".html_safe end |
#render_attributes ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ecrire/app/helpers/content_tag_helper.rb', line 56 def render_attributes attrs = @attributes.dup if css.empty? attrs.delete :class else attrs[:class] = css.to_s end attrs.keys.map do |k| "#{k}='#{attrs[k]}'" end.join(' ').prepend(' ').html_safe end |
#tag_options(*args) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ecrire/app/helpers/content_tag_helper.rb', line 29 def (*args) = nil args.each do |a| if a.is_a?(Hash) = a break end end ( || {}).with_indifferent_access end |