Class: Pageflow::WidgetType
- Inherits:
-
Object
- Object
- Pageflow::WidgetType
- Defined in:
- lib/pageflow/widget_type.rb
Direct Known Subclasses
Defined Under Namespace
Classes: NotFoundError, Null
Instance Method Summary collapse
-
#enabled_in_editor? ⇒ Boolean
Override to return false to hide widget in editor.
-
#enabled_in_preview? ⇒ Boolean
Override to return false to hide widget in entry preview.
-
#insert_point ⇒ Object
Point in DOM where widget should be inserted.
-
#name ⇒ Object
Override to return a string in snake_case.
-
#render(template, entry) ⇒ Object
Override to return html as string.
-
#render_head_fragment(template, entry) ⇒ Object
Override to return html that should be placed in the head element of the page.
-
#render_head_fragment_with_configuration(template, entry, _configuration) ⇒ Object
Override instead of render_head_fragment to use the widget configuration.
-
#render_with_configuration(template, entry, _configuration) ⇒ Object
Override instead of render to use the widget configuration.
-
#roles ⇒ Object
Override to return array of role names.
-
#translation_key ⇒ Object
Name to display in editor.
Instance Method Details
#enabled_in_editor? ⇒ Boolean
Override to return false to hide widget in editor.
22 23 24 |
# File 'lib/pageflow/widget_type.rb', line 22 def enabled_in_editor? true end |
#enabled_in_preview? ⇒ Boolean
Override to return false to hide widget in entry preview.
27 28 29 |
# File 'lib/pageflow/widget_type.rb', line 27 def enabled_in_preview? true end |
#insert_point ⇒ Object
Point in DOM where widget should be inserted. Possible values are ‘:bottom_of_entry` (default) or `:before_entry`.
35 36 37 |
# File 'lib/pageflow/widget_type.rb', line 35 def insert_point :bottom_of_entry end |
#name ⇒ Object
Override to return a string in snake_case.
12 13 14 |
# File 'lib/pageflow/widget_type.rb', line 12 def name raise(NotImplementedError, 'WidgetType subclass needs to define name method.') end |
#render(template, entry) ⇒ Object
Override to return html as string.
46 47 48 |
# File 'lib/pageflow/widget_type.rb', line 46 def render(template, entry) template.render(File.join('pageflow', name, 'widget'), entry: entry) end |
#render_head_fragment(template, entry) ⇒ Object
Override to return html that should be placed in the head element of the page. Not supported inside the editor.
59 60 61 |
# File 'lib/pageflow/widget_type.rb', line 59 def render_head_fragment(template, entry) '' end |
#render_head_fragment_with_configuration(template, entry, _configuration) ⇒ Object
Override instead of render_head_fragment to use the widget configuration. Return html as string that should be placed in the head element of the page.
53 54 55 |
# File 'lib/pageflow/widget_type.rb', line 53 def render_head_fragment_with_configuration(template, entry, _configuration) render_head_fragment(template, entry) end |
#render_with_configuration(template, entry, _configuration) ⇒ Object
Override instead of render to use the widget configuration. Return html as string.
41 42 43 |
# File 'lib/pageflow/widget_type.rb', line 41 def render_with_configuration(template, entry, _configuration) render(template, entry) end |
#roles ⇒ Object
Override to return array of role names.
17 18 19 |
# File 'lib/pageflow/widget_type.rb', line 17 def roles raise(NotImplementedError, 'WidgetType subclass needs to define roles method.') end |
#translation_key ⇒ Object
Name to display in editor.
7 8 9 |
# File 'lib/pageflow/widget_type.rb', line 7 def translation_key "pageflow.#{name}.widget_type_name" end |