Class: InplaceEditingHelper::EmptyTag
- Inherits:
-
Object
- Object
- InplaceEditingHelper::EmptyTag
- Includes:
- ActionView::Helpers::CaptureHelper
- Defined in:
- app/helpers/inplace_editing_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, attributes = {}) ⇒ EmptyTag
constructor
A new instance of EmptyTag.
- #render(content) ⇒ Object
- #render_attributes ⇒ Object
Constructor Details
#initialize(name, attributes = {}) ⇒ EmptyTag
Returns a new instance of EmptyTag.
185 186 187 188 189 |
# File 'app/helpers/inplace_editing_helper.rb', line 185 def initialize(name, attributes = {}) @name = name @attributes = attributes.with_indifferent_access @attributes[:class] = Tag::CSS.new(attributes[:class]) end |
Instance Attribute Details
#css ⇒ Object (readonly)
Returns the value of attribute css.
183 184 185 |
# File 'app/helpers/inplace_editing_helper.rb', line 183 def css @css end |
#id ⇒ Object
Returns the value of attribute id.
182 183 184 |
# File 'app/helpers/inplace_editing_helper.rb', line 182 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
183 184 185 |
# File 'app/helpers/inplace_editing_helper.rb', line 183 def name @name end |
Instance Method Details
#[](k) ⇒ Object
195 196 197 |
# File 'app/helpers/inplace_editing_helper.rb', line 195 def [](k) @attributes[k] end |
#[]=(k, v) ⇒ Object
191 192 193 |
# File 'app/helpers/inplace_editing_helper.rb', line 191 def []=(k,v) @attributes[k] = v end |
#render(content) ⇒ Object
199 200 201 |
# File 'app/helpers/inplace_editing_helper.rb', line 199 def render(content) "<#{name}#{render_attributes} />".html_safe end |
#render_attributes ⇒ Object
203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'app/helpers/inplace_editing_helper.rb', line 203 def render_attributes attrs = @attributes.dup if self[:class].empty? attrs.delete :class else attrs[:class] = self[:class].to_s end attrs.keys.map do |k| "#{k}='#{ERB::Util.html_escape(attrs[k])}'".html_safe end.join(' ').prepend(' ') end |