Module: TipTap::HtmlRenderable
- Includes:
- ActionView::Helpers::AssetTagHelper, ActionView::Helpers::TextHelper
- Included in:
- Node
- Defined in:
- lib/tip_tap/html_renderable.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#output_buffer ⇒ Object
ActionView::Helpers::TagHelper requires output_buffer accessor This is included by ActionView::Helpers::TextHelper.
Class Method Summary collapse
Instance Method Summary collapse
- #html_attributes ⇒ Object
- #html_class_name ⇒ Object
- #html_tag ⇒ Object
- #inline_styles ⇒ Object
- #to_html ⇒ Object
Instance Attribute Details
#output_buffer ⇒ Object
ActionView::Helpers::TagHelper requires output_buffer accessor This is included by ActionView::Helpers::TextHelper
13 14 15 |
# File 'lib/tip_tap/html_renderable.rb', line 13 def output_buffer @output_buffer end |
Class Method Details
.included(base) ⇒ Object
15 16 17 |
# File 'lib/tip_tap/html_renderable.rb', line 15 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#html_attributes ⇒ Object
61 62 63 |
# File 'lib/tip_tap/html_renderable.rb', line 61 def html_attributes {style: inline_styles, class: html_class_name}.reject { |key, value| value.blank? } end |
#html_class_name ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/tip_tap/html_renderable.rb', line 47 def html_class_name classes = self.class.html_class_name case classes when Proc instance_eval(&classes) else classes end end |
#html_tag ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/tip_tap/html_renderable.rb', line 37 def html_tag tag = self.class.html_tag case tag when Proc instance_eval(&tag) else tag end end |
#inline_styles ⇒ Object
65 66 67 68 69 |
# File 'lib/tip_tap/html_renderable.rb', line 65 def inline_styles styles = [] styles << "text-align: #{attrs["textAlign"]};" if attrs["textAlign"] styles.join(" ") end |
#to_html ⇒ Object
57 58 59 |
# File 'lib/tip_tap/html_renderable.rb', line 57 def to_html content_tag(html_tag, safe_join(content.map(&:to_html)), html_attributes) end |