Class: Skyline::LinkRef
- Defined in:
- app/models/skyline/link_ref.rb
Instance Attribute Summary
Attributes inherited from InlineRef
Instance Method Summary collapse
-
#to_end_html ⇒ Object
- Render html end tag for specified RefObject ==== Parameters skyline_attr<Boolean>
-
boolean that sets if skyline attributes should be added to the html tag.
-
#to_start_html(skyline_attr = false, options = {}) ⇒ Object
- Render html start tag for specified RefObject ==== Parameters skyline_attr<Boolean>
-
boolean that sets if skyline attributes should be added to the html tag.
Methods inherited from InlineRef
convert, hash_refs_for_object, parse_html
Instance Method Details
#to_end_html ⇒ Object
Render html end tag for specified RefObject
Parameters
- skyline_attr<Boolean>
-
boolean that sets if skyline attributes should be added to the html tag
Returns
- String
-
html link closing tag
31 32 33 |
# File 'app/models/skyline/link_ref.rb', line 31 def to_end_html html_str = "</a>" end |
#to_start_html(skyline_attr = false, options = {}) ⇒ Object
Render html start tag for specified RefObject
Parameters
- skyline_attr<Boolean>
-
boolean that sets if skyline attributes should be added to the html tag
Returns
- String
-
html link tag
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/skyline/link_ref.rb', line 9 def to_start_html(skyline_attr = false,={}) .reverse_merge! :nullify => false skyline_attr_str = "" href = "broken" if !self.referable_id.blank? linked_file = self.referable_type.constantize.find_by_id(self.referable_id) href = linked_file.url unless linked_file.blank? end skyline_ref_id = [:nullify] ? "" : self.id skyline_attrs = "skyline-ref-id=\"#{skyline_ref_id}\" skyline-referable-id=\"#{self.referable_id}\" skyline-referable-type=\"#{self.referable_type}\"" if skyline_attr = self..collect{|k,v| "#{k}=\"#{v}\""}.join(" ") html_str = "<a href=\"#{href}\" #{} #{skyline_attrs}>" end |